Firefox an IE displaying css code differently to Chrome - html

So on my website I have css role over buttons, and everything displays as it should in Chrom but in IE and Firefox the height is larger so you can see too much of the image.
Here's the website its happening on http://www.dillonbrannick.com/ I'm just focusing on one of the buttons, but it is happening with all 4 of them.
Here's the code that effects the home button.
Inside the body and nav tags
<nav class="body">
<div class="links nav" id="home-nav">
<a href="#"
onclick=" toggle_visibility_1('illustrations'); toggle_visibility_1('illustration-sub'); toggle_visibility_1('painting-sub'); toggle_visibility_1('paintings'); toggle_visibility_1('animation'); toggle_visibility_1('contact'); toggle_visibility_1('box'); toggle_visibility_2('homeimage'); toggle_visibility_2('homebio'); toggle_visibility_2('facebook'); toggle_visibility_2('google');">
</a>
</div>
</nav>
I'd imagine the Javascript doesn't effect it as all it does is diplay on/off elements so it has nothing to do with dimensions.
here's the css:
.body{
position:absolute;
left:50%;
top:50%;
}
nav{
margin: -125px 0 0 -44.5px;
}
.nav{
position:absolute;
width: 89px;
}
.nav a{
height: 107.5px;
}
.links a{
display: block;
margin: auto auto auto auto;
cursor: pointer;
outline: transparent solid 0px;
}
#home-nav {
margin: -60px 0px 0px -140px;
}
#home-nav a{
background: url('http://dl.dropbox.com/u/70582811/home.link.png') no-repeat left top;
}
#home-nav a:hover{
background-position: left -107.5px;
}
I know the body class probably doesn't make any difference to the problem, but I just wanted to show everything that effects the button.
As you can see in these two images(left:Chrome, right: IE and Firefox). There is blue appearing just underneath the grey bar that shouldn't be there, that is part of the other half of the image that is then shifted up onrollover. As you can see on my website.
Thanks in advance,
Dillon Brannick.

I think your problem is the use of .5
.nav a{
height: 107.5px;
}
Browsers probably handle that differently. I don't think there exists something like half a pixel.
Edit : just try 107px, and then 108px. I think one of them should give u the desired result. 107px probably. Firefox takes 107.5px as 108px.

Related

Footer gets cut off?

I'm having some issues with parts of the footer on my website getting cut of on different browsers.
On my website here http://reportalert.info/index-test.php, the twitter, rss and share icons get cut off and move around slightly when on different browsers. I've tried changing the background position and padding of each of the icons but I can't seem to get it to work across different browsers. Any suggestions on how to fix this?
Here is the code that I have for the footer:
#footer
{
clear: both;
font-family: "Droid Serif";
margin:10px 0;
padding-bottom:60px;
width:100%;
height:10px;
text-align:left;
font-size:80%;
color:#444;
}
a.ftwitter
{
background:url(http://reportalert.info/images/nra/ra-share.png/images/nra/ra-twitter.png) left no-repeat;
background-position:0 -22.5px;
padding:3px 55px;
}
a.ftwitter:hover
{
background-position:0 0;
padding:4px 55px;
}
a.frssfeed
{
background:url(http://reportalert.info/images/nra/ra-share.png/images/nra/ra-feed.png) left no-repeat;
background-position:0 -26.5px;
padding:5px 55px;
}
a.frssfeed:hover
{
background-position:0 0;
padding:6px 55px;
}
a.fshare
{
background:url(http://reportalert.info/images/nra/ra-share.png) left no-repeat;
background-position:0 -22.5px;
padding:3px 60px;
}
a.fshare:hover
{
background-position:0 0;
padding:4px 60px;
}
Thanks in advance for your help
Padding works differently in every browser, that's why your icons gets cut off in Chrome.
I would use a specific width and height instead.
Instead of padding, try using width and height. And add a display: inline-block. Here for example:
a.ftwitter
{
display: inline-block;
background:url(http://reportalert.info/images/nra/ra-share.png/images/nra/ra-twitter.png) left no-repeat;
background-position:0 -22.5px;
width: 110px;
height: 22px;
}
I think this might help. Apply this to your icons:
position:relative;
z-index:99;
The icons that get cut off are all empty a elements. Because it's an inline flow element, that means it collapses to default text height - 20 pixels in the font you use, while the Twitter icon is 22, hence causing 2 pixels to be cut off.
Set the anchors to display:inline-block, or another block layout style fitting in your layout, and the correct height which is then allowed, and it's solved.

CSS Overridden: Why Doesn't Search Box Float right?

I'm at a total loss on why I can't align the Search box to the left
The Search and RSS feed align on the test page:
http://scottjaxon.com/devsite/testnivo48.html
As it is on the home page (with a pic instead of nivo slider)
http://scottjaxon.com/devsite/index.html
I don't get it. I gotta be missing the smallest thing!
#wrapper #user1 #feahome #searchhome {
float: right;
color: #FFFFFF;
height: 22px;
margin-top: 8px;
padding: 0px 20px 0px 20px;
Or is it something with the NivoSlider CSS?
.nivoSlider {
position:relative;
width:100%;
height:auto;
overflow: hidden;
}
.nivoSlider img {
position:absolute;
top:0px;
left:0px;
}
.nivo-main-image {
display: block !important;
position: relative !important;
width: 100% !important;
}
Your index.html and testnivo48.html have different dom structures.
In index.html, the feahome div tag is the parent of rsshome and searchhome div tags; but in the testnivo48.html, they are all on the same level.
That's why the following css rule (in http://scottjaxon.com/devsite/css/style.css) gets applied on index.html, but ignored in testnivo48.html
#wrapper #user1 #feahome #searchhome {
...
}
After you fix the html, your problem might get solved.
I was looking at the CSS for both and the only thing I saw that was different in your
CSS compared to the CSS for http://scottjaxon.com/devsite/index.html is this:
#wrapper #user1 #feahome #searchhome {
float: LEFT; // the working version has it floated left as well
color: #FFFFFF;
height: 22px;
margin-top: 8px;
padding: 0px 20px 0px 20px;
Give it a shot and see if that works.
It may be a prioritizing problem. Using div#searchhome will give it a higher priority.

Trying to Reduce HTTP Requests With CSS Sprites But Now Images Don't Appear Properly

To try and reduce the number of HTTP requests I have combined groups of related images into sprites.
I understand the methodology behind it but I can't seem to get it to work correctly for the ones I am working one and would love some help.
Here is the new markup and css (previous markup just had individual img tags wrapped in the anchor tag):
<div id="footer-flags">
<ul>
<li class="countryName">Region: </li>
<li class="active countryFlag" id="uk"><a title="United Kingdom" href="javascript:void(0);"></a></li>
<li class="countryFlag" id="us"><a title="United States" target="_blank" href="http://www.us-site.us"></a></li>
... 5 more
</ul>
</div>
CSS is as seen below:
#footer-flags {
float:right;
}
#footer-flags ul {
list-style-type: none;
margin:-3px 0 0 0;
overflow:hidden;
padding:0;
}
#footer-flags ul li {
background-image: url(/img/flags/flags-sprite.jpg);
height: 11px;
width: 14px;
float:left;
padding-left:5px;
padding-top:3px;
}
#footer-flags #de {
background-position: 0px 0px;
}
#footer-flags #fr {
background-position: 0px -11px;
}
#footer-flags #hr {
background-position: 0px -22px;
}
#footer-flags #ie {
background-position: 0px -33px;
}
#footer-flags #nl {
background-position: 0px -44px;
}
#footer-flags #uk {
background-position: 0px -55px;
}
#footer-flags #us {
background-position: 0px -66px;
}
#footer-flags ul li.active {
background:url("/img/flags/flag-highlight.png") no-repeat scroll left top transparent;
margin-right:-5px;
padding:3px 5px 5px;
}
The sprite image is 14px x 77px (so the flags are positioned on top of each other).
Here is a fiddle if anyone prefers it: http://jsfiddle.net/WNXNz/4/
The error itself is just that the flag images are strewn all over the place and the links don't seem to be there aswell, i.e. the images aren't clickable.
From what I can see I think I have implemented it correctly but it's likely my CSS is a nightmare because I have only had to use a sprite before and it was just for one image.
CSS Sprites shouldn't be used for HTML img. You now have empty links: this is bad for accessibility and SEO.
Accessibility: you can check the relevant WCAG 2.0 Technique H30: Providing link text that describes the purpose of a link for anchor elements
People that disable images, CSS, use a screen reader or use the High Contrast mode in Windows won't be able to know there's a link there or won't know what it can possibly do.
SEO: I'm not a SEO specialist, all I can tell is that searchbots will have to guess from the destination what is the purpose of your link, that's not by far the best way to rank well in search engines.
That said, CSS sprites are great for background images :)

Remove 3D push effect on a button

I'm trying to remove all effects on a HTML Button element.
The HTML:
<div id="go">
<button onclick="load.update(true,cards.id);" type="submit"></button>
</div>
The CSS:
#header #go button{
display:block;
border:0 none;
cursor:pointer;
outline:none;
vertical-align:top;
width:18px;
height:33px;
background:url('../images/cards/go.png'); //Just an image to replace it all.
}
In Chrome and Firefox this works fine, but in IE (8 at least) the "push" effect of the button is still there when the button is clicked (EG the offset)
Is there any Tricks i can use to remove this effect?
Thanks in advance!
Diesal.
you need to add background styles to :hover :active :focus as well.
#header #go button:hover {
border: none;
outline:none;
padding: 5px;
background:url('../images/cards/go.png');
}
#header #go button:active {
border: none;
outline:none;
padding: 5px;
background:url('../images/cards/go.png');
}
#header #go button:focus {
border: none;
outline:none;
padding: 5px;
background:url('../images/cards/go.png');
}
I had a similar experience, and was able to fix it in IE8, but not IE7. See it working here:
http://jsfiddle.net/GmkVh/7/
HTML:
<button></button>
CSS:
button {
color:#fff;
background:#000;
border: none;
outline:none;
padding: 5px;
cursor: pointer;
height: 25px;
}
/*
It hits this state (at least in IE) as you're clicking it
To offset the 1px left and 1px top it adds, subtract 1 from each,
then add 1 to the right and bottom to keep it the same width and height
*/
button:focus:active {
padding-top: 4px;
padding-left: 4px;
padding-right: 6px;
padding-bottom: 6px;
color: #ccc;
}
One way would be to get rid of the <button> tag completely and use a <a href=".." /> tag in its place styled the way you want.
Just have the link do a javascript postback.
update (from comments):
one example:
Click Here
Of course, this requires javascript to be enabled and is considered by some to be an abuse of the anchor tag.
There are alternate versions if you are using .net webforms or jQuery.
After you have done whatever you like with the border etc., just put a span inside the button around the text like so:
<button class="button" type="submit"><span class="buttonspan">Blah</span></button>
Then the CSS becomes:
button {position:relative; width:40px; height:20px /* set whatever width and height */}
buttonspan {
height: 30px;
left: 0;
position: absolute;
top: 0;
width: 100%;
}
<div class="calculation_button">
<button type="submit"><span>Count</span></button>
</div>
.calculation_button span {
position: relative;
left: 0;
top: 0;
}
works for me in IE and FF
The following helped for me in IE 10:
button:active {
position: relative;
top: -1px;
left: -1px;
}
It fixed the top perfectly, but left still had background bleed-though for my case. Still looks a bit odd if the user starts clicking and then moves the mouse off the button. Also obviously only enable the rule for relevant IE version(s).
Position relative seemed to have taken care of the problem
Simply have a wrapper within the button:
So
<button>
<div class="content">Click Me</div>
</button>
and set the DIV to position relative with top: 0, left: 0
Example below:
http://jsfiddle.net/eyeamaman/MkZz3/
It's a browser behaviour, a simple solution is to use a link tag instead of button (since you're calling a javascript function).
<img src="myimg"/>
If you still want to use the , I've found that there are some characteristics on each browser (in a simple debug):
Chrome adds outline and padding
Firefox adds a whole lot of stuff with the standart button border
IE messes with the inner text position
So to fix them, you have to manipulate the pseudo selectors for the button behaviour. And for IE, a good solution is to envolve your text on a element, and make it relative positioned. Like so:
<button type="button" class="button"><span>Buttom or Image</span></button>
<style>
button,
button:focus,
button:active{
border:1px solid black;
background:none;
outline:none;
padding:0;
}
button span{
position: relative;
}
</style>
Pen
This is a duplicate question

How to make a CSS rollover image? (sprite)

I'm just trying to use this little trick I saw in one of my web design magazines to make a little image rollover but I'm having just a small bit of trouble. My attempt was a terrible fail lol. I just want to see the top half (42px tall) and then the bottom half on rollover (-42px obviously)
width is also 42px. Could someone write something up to make that happen?
image:
http://img826.imageshack.us/img826/6568/homebi.png
It's all about the initial (non-:hover) and final (:hover) values of background-position.
#test {
height: 42px;
width: 42px;
background-image: url(http://img826.imageshack.us/img826/6568/homebi.png);
background-repeat: no-repeat;
background-color: transparent;
background-position: top; /* <-- key step #1 */
}
#test:hover {
background-position: bottom; /* <-- key step #2 */
}
Demo
As per your comment re: wrapping the <div> with an anchor (<a>), here's what to do:
Swap the <div> out for a <span>. This is because valid children of anchors must be inline elements
But inline-displayed elements won't behave accept dimensions! So, fix this new problem with one additional CSS property: display: inline-block on the span.
Demo 2
Try this:
<style type="text/css">
.menu {
}
.menu a {
float: left;
display: inline;
width: 42px;
height: 42px;
text-decoration: none;
}
.menu a span {
display: block;
overflow: hidden;
height: 0;
}
.menu .home {
background: transparent url(http://img826.imageshack.us/img826/6568/homebi.png) 0 0 no-repeat;
}
.menu .link:hover {
background-position: 0 -42px;
}
</style>
<div class="menu">
<span>Home</span>
</div>
Heres the bare bones for an image rollover.
the css
.rollover{display:block; height:42px; width:42px; background:url(http://img826.imageshack.us/img826/6568/homebi.png) top;}
.rollover:hover{background-position:bottom;}
.rollover span{display:none}
The html
<span>Home</span>
The important part is the background position, which on the buttons normal state is set to 'top', when you rollover the background postion is 'bottom'.
Assuming your image which contains both button states is 84px high this will work fine.