Image Rollovers Inside Facebook Tab Page - css

I'm trying to use a simple CSS-sprite for image-based rollovers inside a Facebook Tab page, and the background images are being stripped by Facebook. To be clear, this problem only occurs inside a Tab page, but not in the main application itself.
Facebook also appears to be extremely picky about when it strips background images - background images applied to anchor tags are removed, but background images applied to the list element containing the anchor remain intact.
For example, given the markup:
<li><img src="http://absolute/path/to/spacer-image.png" alt="" width="172" height="43" /></li>
the following CSS will apply a background to the list element successfully:
li {
background: url(http://absolute/path/to/some/image.jpg) no-repeat 0 0;
}
but the same CSS applied to the child anchor tag is stripped out by Facebook:
li a {
background: url(http://absolute/path/to/some/image.jpg) no-repeat 0 0;
}
Is Facebook actually capable of supporting image-based rollovers inside a tab, and if so, how?

Discovered a solution of sorts through trial and error, though it involves invalidly stacked html and looks pretty nasty.
Modify the markup so a div is inside the anchor tag:
<div><img src="http://absolute/path/to/spacer-image.png" alt="" width="172" height="43" /></div>
and apply the background image to the div instead of the anchor:
li a div {
background: url(http://absolute/path/to/some/image.jpg) no-repeat 0 0;
}
You can then apply the background offset like this:
li a:hover div { background-position: 0 -43px; }
It does work but I'd much rather a less-hacky solution if anyone can suggest something.

Related

Resize an image within a parent element class

This seems simple enough but I am trying to override a style class on an image tag.
A user uploads content and images using the CKEditor wysiwyg. The issue is if the user doesn't resize the image before posting and then I try to show their HTML on the page the image is wider than the container.
How can I override it with CSS?
<p class="post-content text-muted break-text mb-none">
<p><img alt="" src="https://example.com/1234.png" style="height:1598px; width:1594px" /></p
</p
I tried this css but couldn't override it.
<style>
.post-content img {
width:400px !important;
}
</style>
Since this is user-generated content, I can't add a class directly to the img otherwise I would, if that makes sense. Thanks
Your HTML has a <p> tag inside a <p> tag so would likely have rendered as two separate paragraphs, and the one containing the image wouldn't have the .post-content class on it.
Aside from that, you might be best of with this CSS, as this will keep the image at 100% width but no larger than its actual size.
.post-content img {
max-width: 100%;
height: auto !important;
}

Align icons and images to right, textarea to left (twitter-Bootstrap)

TL;DR : Before you read anything, the desired end-result is illustrated in the image below, otherwise refer to the JSFiddle. Preferably, I would like to only use CSS and not modify the DOM structure.
The icons must be aligned completely to the right (hence the .pull-right), but the icons must be stacked vertically (Sometimes some icons must not appear, so they are .hidden, like the .fa-undo icon in the second row).
(When I say 'the icons' i mean the <i> tags and the <img> tag)
The icons must not make the textarea go down (no margin on top of the textarea).
Hopefully, the WIDTH of the textarea would be dynamic and not statically put to width: 90%; for example. It should take as much width as possible, without interfering with the vertical icon stack.
Here is the end result that I want (in a perfect world this would be done using CSS and the same HTML DOM I provided)
In general, images that are UI elements, and not content, should be CSS backgrounds, not inline images. You then use class names to control the image content.
You should be doing this, or something similar:
td.fr {
background-image:url(/images/fr.gif);
background-repeat:no-repeat;
background-position: top right;
}
The same should go for your buttons. Use <button> and style the background.
Not exactly what you wanted I'm afraid, but this is how I'd achieve that result:
fiddle
<div class="pull-right icons">
<img src="http://www.convertnsftopst.net/images/gb.gif" class="pull-right" />
<i class="fa fa-reply"></i>
</div>
td .icons{
width:20px;
text-align:center;
}
Here is the end result that I want (in a perfect world this would be done using CSS and the same HTML DOM I provided)
I was unable to do it without adding another pull-right container, I fear that doing it with only CSS would end up being an odd hack
Fixed here : http://jsfiddle.net/QTXxp/2/
What was lacking when I asked this question was the clear:right; and the use of <div> (or display: block;)
Here is the CSS (if you're too lazy to open the JSFiddle) with the addition of the boostrap class pull-right on the div.icons
textarea.hover-edit {
width: 90% !important;
}
div.icons {
width: 10% !important;
}
div.icons > div > i.fa {
margin-top: 4px;
margin-right: 4px;
}
div.icons > div.action-icon-right {
float:right;
clear:right;
}

CSS sprite displaying all images

I am trying to use 1 single image file containing 4 images and display them using CSS sprite. Somehow, all 4 images are displayed. I was referring to one of the examples in w3schools.
<div id="ViewTypeContainer" style="float: right; margin-top: 10px; margin-right: 10px;">
<img id="calendarView" alt="" src="/Images/ButtonToggle.png" height="1" width="1"/>
<img id="grdView" alt="" src="/Images/ButtonToggle.png" height="1" width="1" />
</div>
CSS:
#ViewTypeContainer img#calendarView {
width:82px;
height:82px;
background: url('/Images/ButtonToggle.png') 0 0;
}
#ViewTypeContainer img#grdView {
width:82px;
height:82px;
background: url('/Images/ButtonToggle.png') -30px 0;
}
My image file is in .png format:
Can anyone spot my mistake? Thanks.
Yeah: your img tags have their src attributes pointing at the sprite image too.
If you want the sprite image to show up with the positioning specified in the CSS, the images need a transparent image in their src attribute.
Working example using your image here (I've used a data-URI for the transparent GIF):
http://jsfiddle.net/7Ns8L/
And here's another example using what might be more semantic HTML (depending on what these controls actually do), i.e. no <img> tags:
http://jsfiddle.net/7Ns8L/1/
Exactly. You're giving a background image to an image. So the IMG tag is displayed as normal size right over the top of your sprite. The concept of sprites is easiest applied if you work with background-position css property. You could either go through the trouble of generating a transparent .png for your IMG tag source (I wouldn't recommend it), or just replace the IMG tag with a div and give the div the same ID and CSS.

Link with background image

I have some 10 buttons with image-text and hover states for each.
What I want to do is use background-position, width and height to only show the part of the background image sprite and hover background-position to show the hover style.
I'll also use an image replacement class on the element so that it remains accessible and indexable.
So (measurements are random):
[CSS]
.menu{background-image:url(path/to/sprite.png);}
.button-1{width:200px;height:30px;background-position:0 0;}
.button-1:hover{background-position:0 -30px;}
.button-2{width:250px;height:30px;background-position:100px 0;}
.button-2:hover{background-position:100px -30px;}
/* Image Replacement Class (H5BP, #necolas && BEM) */
.ir{border:0;font:0/0 a;text-shadow:none;color:transparent;background-color:transparent;}
[HTML]
Button 1
Button 2
What I want to know is if that is a good way of doing this or should it be done differently, like:
<img src="image.png" width="200" height="30" alt="Button 1"/>
Then with JavaScript swap the image on hover.
Is there any difference between the two in terms of accessibility and robots?
Thank you.
What you are doing is correct. Do not forget to add a display: block; to that link. Something else you can do is putting the actual link text in a span and then positioning that span absolute out of the screen. Like so:
<span>Home page</span>
And in your css file:
a > span {position: absolute; top: -10000px;}

Different Links CSS Hover change a picture

I would like a CSS hover affect for multiple links that affect the same image. If you look at this example site I have Repair, Sales, Upgrades and Data Recovery links. When you hover over any one of them I would like the image to their left to change. You can hover over the image currently there to see what I mean.
website: http://ctuchicago.squarespace.com/
I would create a box that contains the image and all of the links. Then when the box is hovered over the image will change. This doesn't get you exactly what you want - which is only hovering over the link changes the image, but I think it is close enough and far easier.
http://jsfiddle.net/mrtsherman/D5ZRs/
div:hover img { background: url('blah'); }
<div>
<img src="" />
Repair
Sales
</div>
Put the image inside the a tag. Then use position: relative to position the image...
for example
a img{
position: relative;
left: -50px;
}
This seems to work... partially XD
<div class="frontdiv fblankd">
<a href="/audio-video" id="hav" style="width: auto;">
<div style="
height: 80px;
margin-left: 81px;
background: white;
color: black;
">
<h3>AUDIO / VIDEO</h3>
<p>Music Server, Home Theatre, Zone Systems, Universal Remote Control</p>
</div>
</a>
</div>
The basic idea is to have your content in the a tag (like ever body has been saying).
What I've done with the styling is set the anchor to width:auto and wrapped the content in a div. this div I then gave a height of 80px, left margin of 81px, background of white and font color of black.
Wrap the <p>, and <h3> tags inside the <a> tags.

Resources