set or shift background image via css/less for firefox - css

I have the below which works really well for all browsers except Firefox.
Basically it loads a background sprite image and positions it depends on the classes. Is there a work around for Firefox or a better way?
example page - http://smf.jynk.net/events/making-progress-boosting-the-skills-and-wage-prospects-of-the-low-paid/
.social__icon--share{
.svg-bg('smf-site-icons-02',#position: -200px -200px) ;
.single-publications &{
background-position-y: -200px;
}
.single-events &{
background-position-y:-400px;
}
.single-post &{
background-position-y:-600px;
}
display: inline-block;
width: 31px;
height: 31px;
&.social__icon--share--twitter{
background-position-x: -200px;
}
&.social__icon--share--facebook{
background-position-x: -800px;
}
&.social__icon--share--google{
background-position-x: -1000px;
}
&.social__icon--share--linkedin{
background-position-x: -1200px;
}
&.social__icon--share--pinterest{
background-position-x: -1400px;
}
}

Found a workaround with a mixing -
.bgpos(#ypos) {
&.social__icon--share--twitter{
background-position: -200px #ypos;
}
&.social__icon--share--facebook{
background-position: -800px #ypos;
}
&.social__icon--share--google{
background-position: -1000px #ypos;
}
&.social__icon--share--linkedin{
background-position: -1200px #ypos;
}
&.social__icon--share--pinterest{
background-position: -1400px #ypos;
}
}
// icons.less
.single-publications &{
.bgpos(-200px);
}
.single-events &{
.bgpos(-400px);
}
.single-post &{
.bgpos(-600px);
}

Related

Background image not covering the whole space

I am sure I am missing something simple, but I can't seem to find it.
On michelleforboe.com, I am trying to get the background image to cover the whole space of a div. I am using calc to set the height of the div, but the div is resolving slightly higher that what it should be. Also, if you scroll down & back up, the black bar at the bottom of the image is even larger. There is a another div sitting on top of the image; I had thought maybe that was causing the extra space, but I don't think it is. Anyone see what I am missing?
.home-section-1 .wrap {
margin-left: 0;
}
.home .site-inner {
margin-top: 140px;
}
.home-section-1.widget-area {
background-size: 100% calc(100vw/2.9);
background-position: 50% 50%;
height: calc(100vw/2.9);
padding-top: 0;
padding-bottom: 0;
}
#text-7 {
height: calc(100vw/2.9);
}
#text-7 .widget-wrap {
height: 100%;
position: relative;
}
#text-7 .widget-wrap .textwidget {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#text-7 a.button {
font-size: 2vw;
padding: 1vw;
}
.home-section-1 .widget-wrap {
width: 50%;
}
try this css
.home-section-1.widget-area {
background-size: cover !important;
background-position: 50% 50%;
height: auto;
padding-top: 0;
padding-bottom: 0;
}
If u wanna full screen of image then remove height from css
.home-section-1.widget-area {
background-size: cover !important;
background-position: 50% 50%;
padding-top: 0;
padding-bottom: 0;
}

Making a background image transparent without changing the rest of the div

I have a div with a background color and a background image. The div calls this class:
.cakebg {
background-color: #F8BBD0;
background-image: url(img/cake.png);
background-size: 25%;
background-position: right top;
background-repeat: no-repeat;
}
I am trying to make only the image somewhat transparent. I tried this:
.cakebg {
background-color: #F8BBD0;
background-image: url(img/cake.png);
opacity: 0.6;
background-size: 25%;
background-position: right top;
background-repeat: no-repeat;
}
But that makes the entire div transparent.
So I tried this:
.cakebg {
background-color: #F8BBD0;
background-image: url(img/cake.png) opacity(0.6);
background-size: 25%;
background-position: right top;
background-repeat: no-repeat;
}
But that makes the image disappear entirely. Can this be done?
What you're trying to do on that single element isn't possible, but there's plenty of ways that could do the same thing with very little extra effort. Probably the best way would be to either add an additional child element to the .cakebg element with the same dimensions that only has the background image, with opacity. Such as:
.cakebg .child-element {
height: 100%;
width: 100%;
background-image: url(img/cake.png);
opacity: 0.6;
}
If you're trying to keep your markup clean, you can even add this as a pseudoelement. Such as the following:
.cakebg:after {
content: "";
height: 100%;
width: 100%;
background-image: url(img/cake.png);
opacity: 0.6;
}
If neither of those methods work, a last resort could be editing the image to have that opacity baked in from your favorite editing software. Hopefully some of these methods might help!
There is no CSS property background-opacity, but you can fake it by inserting a pseudo element with regular opacity the exact size of the element behind it.
.cakebg {
background-color: #F8BBD0;
background-size: 25%;
position: relative;
}
.cakebg::after {
content: "";
background: url(img/cake.png);
opacity: 0.5;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
z-index: -1;
}
OR you can simply use an trasparent png image as background
There is no CSS property to make just the background transparent, but you can fake it by inserting a pseudo element with the same size of element behind it and change the opacity of this.
.cakebg {
background-color: #F8BBD0;
background-size: 25%;
background-position: right top;
background-repeat: no-repeat;
}
.cakebg::after {
content: "";
background-image: url(img/cake.png);
opacity: 0.5;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
z-index: -1;
}
Please note that that question was already asked quite often, read here for example.

How can I use #for in sass to assign background positions to multiple classes

Ok so here's my code:
.file-icon,.folder-icon{
$size:24px;
position: absolute;
top: 10px;
left: 44px;
display: block;
float: left;
width: $size;
height: $size;
margin-right: 10px;
background: $driveIcon;
&.folder-close{
background-position: 0 -72px;
&.folder-open{
background-position: -$size -72px;
}
}
&.archiveIcon{
background-position: -$size*2 -72px;
}
&.audioIcon{
background-position: -$size*3 -72px;
}
&.brokenIcon{
background-position: -$size*4 -72px;
}
&.docIcon{
background-position: -$size*5 -72px;
}
&.imgfile{
background-position: -$size*6 -72px;
}
&.pdfIcon{
background-position: -$size*7 -72px;
}
&.pptx{
background-position: -$size*8 -72px;
}
&.txtIcon{
background-position: -$size*9 -72px;
}
&.unknown{
background-position: -$size*10 -72px;
}
&.videoIcon{
background-position: -$size*11 -72px;
}
&.xlsIcon{
background-position: -$size*12 -72px;
}
&.viewer{
background-position: -$size*13 -72px;
&.folder-open{
background-position: -$size*14 -72px;
}
}
&.owner{
background-position: -$size*15 -72px;
&.folder-open{
background-position: -$size*16 -72px;
}
}
&.moderator{
background-position: -$size*17 -72px;
&.folder-open{
background-position: -$size*18 -72px;
}
}
}
What I want to do is automate this assigning of background positioning. I tried using #for for the actual statement but not able to figure out how to assign the results one by one to my custom second classes. Please help me out, i'm a beginner in sass. Thankyou.
This is what I've done up till now:
#for $i from 0 to 18{ background-position: -($size*$i} -72px; }
Well, you can use sass lists for your sprites.
Here is an approach:
$list: archiveIcon, audioIcon;
$size: 24px;
$totalClasess: 2;
#each $value in $list {
&.#{$value} {
background-position: -($size*$totalClasses) -72px;
#if $value == folder-close {
&.folder-open {
background-position: -$size -72px;
}
}
}
$totalClasses: $totalClasses + 1;
}
You have to complete the list with all your classes.
Regards.

Positioning buttons under slideshow in CSS

I am trying to re-position some navigation tools in CSS but anything I try doesn't work. Is there a way I could group it together and move it as a div?
I've tried adjusting the background properties and also playing with padding and margins of the individual tags. I'm not sure how else it can be done?
This is the code i'm working with:
#slides .slidesjs-navigation {
margin-top:5px;
}
a.slidesjs-next,
a.slidesjs-previous,
a.slidesjs-play,
a.slidesjs-stop {
background-image: url(images/btns-next-prev.png);
background-repeat: no-repeat;
display:block;
width:12px;
height:18px;
overflow: hidden;
text-indent: -9999px;
float: left;
margin-right:5px;
}
a.slidesjs-next {
margin-right:10px;
background-position: -12px 0;
}
a:hover.slidesjs-next {
background-position: -12px -18px;
}
a.slidesjs-previous {
background-position: 0 0;
}
a:hover.slidesjs-previous {
background-position: 0 -18px;
}
a.slidesjs-play {
width:15px;
background-position: -25px 0;
}
a:hover.slidesjs-play {
background-position: -25px -18px;
}
a.slidesjs-stop {
width:18px;
background-position: -41px 0;
}
a:hover.slidesjs-stop {
background-position: -41px -18px;
}
It's sitting in the bottom of the page! I would like it to sit just beneath the slideshow of images! Any help would be great!

Align icon to right of text (RTL site) with CSS

I'm working on a right to left aligned website (in Hebrew) and would like the icons to appear to the right of the text. For example: http://kaptinlin.com/themes/striking/shortcodes/typography/ at the bottom Contact Us widget, the icon is on the left, I want it on the right.
Here is the relevant code (HTML):
<section id="contact_info-3" class="widget widget_contact_info">
<h3 class="widgettitle">Contact Us</h3>
<p><span class="icon_text icon_phone default">(+40) 111 222 333</span></p>
<p class="contact_address">
<span>city, state</span>
<span class="contact_zip">1111</span>
</p>
</div>
</section>
CSS:
.icon_text {
padding: 0 22px 0 0;
background-image: url("http://kaptinlin.com/themes/striking/wp-content/themes/striking/images/icons.png");
background-repeat: no-repeat;
background-attachment: scroll;
background-color: transparent;
}
#footer .icon_text.default {
background-image: url("http://kaptinlin.com/themes/striking/wp-content/themes/striking/images/footer_icons.png");
}
.icon_globe {
background-position: -390px 0px;
}
.icon_home {
background-position: -360px -30px;
}
.icon_email {
background-position: -330px -60px;
}
.icon_user {
background-position: -300px -90px;
}
.icon_multiuser {
background-position: -270px -120px;
}
.icon_id {
background-position: -240px -150px;
}
.icon_addressbook {
background-position: -210px -180px;
}
.icon_phone {
background-position: -180px -210px;
}
.icon_link {
background-position: -150px -240px;
}
.icon_chain {
background-position: -120px -270px;
}
.icon_calendar {
background-position: -90px -300px;
}
.icon_tag {
background-position: -60px -330px;
}
.icon_download {
background-position: -30px -360px;
}
.icon_cellphone {
background-position: 1px -390px;
}
.icon_text.default {
background-image: url("http://kaptinlin.com/themes/striking/wpcontent/themes/striking/images/icons_black.png");
}
.icon_text.black {
background-image: url("http://kaptinlin.com/themes/striking/wp-content/themes/striking/images/icons_black.png");
}
.icon_text.gray {
background-image: url("http://kaptinlin.com/themes/striking/wp-content/themes/striking/images/icons_gray.png");
}
.icon_text.red {
background-image: url("../images/icons_red.png");
}
.icon_text.orange {
background-image: url("http://kaptinlin.com/themes/striking/wp-content/themes/striking/images/icons_orange.png");
}
.icon_text.magenta {
background-image: url(http://kaptinlin.com/themes/striking/wp-content/themes/striking/images/icons_magenta.png);
}
.icon_text.yellow {
background-image: url("http://kaptinlin.com/themes/striking/wp-content/themes/striking/images/icons_yellow.png");
}
.icon_text.blue {
background-image: url("http://kaptinlin.com/themes/striking/wp-content/themes/striking/images/icons_blue.png");
}
.icon_text.pink {
background-image: url("http://kaptinlin.com/themes/striking/wp-content/themes/striking/images/icons_pink.png");
}
.icon_text.green {
background-image: url("http://kaptinlin.com/themes/striking/wp-content/themes/striking/images/icons_green.png");
}
.icon_text.rosy {
background-image: url("http://kaptinlin.com/themes/striking/wp-content/themes/striking/images/icons_rosy.png");
}
Thanks.
Your icons are background-images so in short you need to adjust the padding, background-position and text-align properties to move it from the left to the right side.
You need to make a few adjustments. First you need to make sure the padding is set to the right side instead of the left side. Then you need to adjust the background-position to put the icons on the right:
.icon_text {
padding: 0 22px 0 0; /* changed from 0 0 0 22px on live site*/
background-image: url("http://kaptinlin.com/themes/striking/wp-content/themes/striking/images/icons.png");
background-repeat: no-repeat;
background-attachment: scroll;
background-color: transparent;
}
.contact_info_wrap .icon_text, .contact_info_wrap .contact_address {
padding-right: 26px; /* changed from padding-left on live site */
}
.icon_phone { /* obviously you would change each of the icons as necessary */
background-position: -72px -210px; /* changed from -180px -210px */
}
However doing this will lead to your icons not being in line with each other down the right side. So you will want to align the text to the right by adjust the p tags:
.contact_info_wrap p {
margin-bottom: 5px;
text-align: right; /* add this */
}
I would guess you would also want your titles to be aligned so:
#footer h3.widgettitle {
color: #FFFFFF;
font-size: 24px;
text-align: right; /* add this */
}
Should you need any further assistance on your rtl question, please visit the Striking support forum and we will assist you. RTL is generally straightforward. We can provide you the code for moving all body text to rtl, and assist with any particular element for which you are uncertain of the element movement.

Resources