Right border not displaying on google chrome - css

I have a div which contains an a with some border. See:
http://webnumbr.com/all
It works great in FF and IE, but why doesn't the right hand side render in Chrome? Is it invalid CSS? (testing in chrome OSX if that matters)

Test case: Included so this question still makes sense after the content at the given URL changes:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html><head><style type="text/css">
div {
float: left;
clear: left;
margin: 3px;
}
span {
border: 1px solid;
}
</style></head><body>
<!-- does not show right border -->
<div><span>With trailing space, no width </span></div>
<!-- does show right border -->
<div><span>No trailing space, no width</span></div>
<div style="width: 40ex;"><span>With trailing space, has width </span></div>
<div style="width: 40ex;"><span>No trailing space, has width</span></div>
</body></html>
Verified in Google Chrome 4.0.266.0 (Official Build 33992) with WebKit 532.6.

I can't tell you the reason why this is happening, but I think I have a fix for you. You have spaces padding your link content, and apparently Chrome isn't handling this very well.
If you remove the extra spacing around the contents of the <a> tags, the problem disappears (I did this in the Chrome inspector tool). So, change:
4,481
to:
4,481
Chrome must handle the space in an odd manner when dealing with a float (if you remove the float property on the search_data class, the border appears as well).

Related

vertically stacked divs have space between them (firefox)

a little css problem that i cannot quite find on SO - although I assume it has been asked before, apologies.
So, here is the html:
<html>
<body style="color:white">
<div class="a" style="width: 70%; background: blue;"><p>helloes helloes helloes</p></div>
<div class="b" style="width: 70%; background: pink;"><p>talk talk talk</p></div>
<div class="a" style="width: 70%; background: blue;"><p>yay! yay! yay!</p></div>
</body>
</html>
lovely.
If i open this in ff, i get three vertically stacked divs - but with space in between them! This is not what i wanted! Drama-rama!
ie renders this as i'd expect, which raises some alarm bells.
ie is 9, ff is 11
cheers,
andrew!
UPDATE a lot of mentioning the "p" tag - why/how is the p tag affecting anything? Isn't it wrapped by the div, and the div has the background color applied? Shouldn't, in fact, the div just be internally bigger, but with no space between adjacent divs?
UPDATE:
So i tried this html instead:
<html style="margin:0px; padding:0px;">
which didn't fix the issue, and also this:
<body style="color: white; margin:0px; padding:0px;">
which also didn't fix the issue - shouldn't the css be inherited by the "p" tag in both cases? Interestingly, i also examined the resultant css with firebug, and the p tags all have a margin and padding of 0...
ideas?
UPDATE: a lot of responses asking me to set padding to 0. This doesn't work. Any more answers stating that and i'll down vote 'em.
UPDATE: the question is really specific about using inline css. I don't actually care for inline css myself, but why is everybody providing css stylesheets for their answer?
UPDATE: somebody mentioned -webkit, and while i'm not using a google chrome at all, it is an interesting idea. I cannot see any ff related extra css that might be causing this problem, anybody have any ideas?
I tried it with Chrome and saw the same behavior. After looking at the underlying CSS (F12), Chrome is applying the following two lines to the <p> tag:
-webkit-margin-before: 1em;
-webkit-margin-after: 1em;
If I add the following to the css the blank lines go away:
-webkit-margin-before: 0px;
-webkit-margin-after: 0px;
Hope that helps!
Basically the P tags are by default taking margin. Add css
p{margin:0px; padding:0px;}
This is because of the auto-generated margin of a <p> element.
Firefox (and others) do this differently than IE.
You can "reset" this simply by doing a p{margin: 0} in your css.
You can do the same for all elements at once (which I recommend) by simply adding * { margin: 0; padding: 0;} in your css.
Small tip: Install a browser extension to inspect the behavior of your elements such as Firebug.
Your <p> tags have vertical margins. Vertical margins in CSS collapse, so that child margins can sometimes apply to parents. See http://www.w3.org/TR/CSS21/box.html#collapsing-margins
I resolved this be specifying a CSS 'line-height' I just set it to the same as the font size and then I got consistent DIV spacing across all browsers.

Empty div height issues under IE

I want to implement a empty div with background color in it.
<html>
<head>
<style>
.dark_green {
background-color: #00D100;
width: 20px;
height: 4px;
}
</style>
</head>
<body>
<div class="dark_green"></div>
</body>
</html>
Under IE7/8/9 the height of this div is not 4px, it automatically change to 19px; Under FF and other chrome it is right.
Any suggestions?
It kind of depends on what you are trying to do. There are a few things that would work:
.dark_green {
[...]
line-height:4px;
}
or
.dark_green {
[...]
overflow:hidden;
}
Would both work.
The reason this is happening is because the text in your DIV (even if it's just whitespace) has a rendered line-height of 19px. The problem browsers are using that value instead of what you are setting as a fallback to not cut off text. Telling the browser that you want the text smaller (font-size:4px;), the line height smaller (line-height:4px;), or the text to get cut off (overflow:hidden;) should correct the issue.
The reasons I wouldn't use font-size in this context are:
It only works because the the line-height that is inherited when you
apply the new font size, so you might as well just set the correct
property.
Certain browsers have a minimum font size which is larger than 4px
(11px on FF, not sure if you can set this in IE), meaning that if
the user had a larger minimum set, your fix wouldn't work.
Add a doctype as the very first line such as <!DOCTYPE html>, to escape quirks mode. This is an important thing to do, or you'll have endless problems with IE.
Once you've done this, your original code will work in IE7 and greater just like it does in Firefox/Chrome.
I found this solution:
font-size: 4px;
add any item to the div you want to collapse, and set the display on that element to none.
if your problem div is
<div class="collapseToZero"></div>
Add something like this:
<span class="nothing"></span>
and add this style for the class
.nothing{display:none;}
and your resulting HTML will look like this
<div class="collapseToZero">
<span class="nothing"></span>
</div>
Now ie 7 will render your problem div with a height of zero instead of font size.
Another way - just to throw this into the mix: add an empty comment as the divs content. Yes its adding extra markup but it does work:
<div><!-- --></div>

general container - IE8 horizontal scrollbar problem

I ran into the following problem:
how to make a general container (HTML + CSS; no javascript)
that is contrained vertically (it has a fixed outer height), so it may have a vertical scrollbar
but that can grow horizontally (as needed by the content of the container), so it never has a horizontal scrollbar
it has to work in IE8, FF, Chrome (no IE7 or earlier)
the solution semms to be be trivial at first
but I can not get rid of the horizontal scrollbar in IE8:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<div style="display: table;" class="container-div-1">
<div style="display: table-cell;" class="container-div-2">
<div style="overflow-y: scroll; height: 19em;" class="container-div-3">
<div style="width: 30em; height: 30em; background-color: red;" class="example-content"></div>
</div>
</div>
</div>
</body>
</html>
in this example, we need a 19em high container, that can grow horizontally, as needed by the content (in this case, the "example-cotent" div)
please don't suggest to modify the "example-content" div, as it is just a sample content (any content could be there)
this problem is the generalization of this issue:
IE8 horizontal scrollbar problem
Floating will probably get the result you're looking for. Check out my example here:
http://jsbin.com/ivegi4/4/edit
I took away the containing divs, as I didn't think they were necessary, but I wouldn't see a problem adding them back in if you absolutely needed them.
Set position: absolute on the container-div-3 div. This will cause the div to shrink-wrap whatever is inside, and works fine in IE8.

Background Color and Italics sets off Internet Explorer 7 bug

The following code demonstrates the issue I'm encountering:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style>
p
{
background-color:#FFF;
}
</style>
</head>
<body>
<img src="http://www.google.com/intl/en_ALL/images/logo.gif" style='float:left;'>
<p><em>This is an italic sentence.</em></p>
<p><strong>This is a bold sentence.</strong></p>
<p>This is a normal sentence.</p>
</body>
</html>
When this code is viewed in IE7, the Google logo will be displayed to the left with 'white horizontal bars' running through it lined up with each paragraph, displayed on the right.
Removing the first line with the <em> tags causes the lines to disappear. Try it yourself. Remove each of the three lines and see how the bug changes.
What in the world is going on with this?
--
Resolution: hasLayout issue. Adding zoom: 1 attribute to em corrects the issue.
This is happening because of the floated image.
When an image is floated it technically does not have any layout of its own. The white bars are the <p> tags, since in CSS you gave them a background of #FFF.
For IE7 is thinks the <p> tags are actually starting at the start of the page on the far left, so it starts them there, but simply bumps the content past the floated image, leaving funny white bars overtop of the floated image.
I would try getting around it by giving your <p> tags left margin. If you make enough left margin to get past the image you shouldn't get those bars anymore.
So try something like...
p{ background-color: #fff; margin-left: 300px; }
You can adjust the left margin but something along those lines should get rid of the white bars for you.
Not sure why it's happening, but there are many ways of making sure it doesn't, including adding display: inline-block to the em.

IE8 issue: div breaks line even though its floated

This looks like IE8 issue. I have two divs that are side by side because I float one of them to left. However, if the content inside of right div gets too big for the window, the right div breaks line and goes under left div. How do I make both divs stay on same level, side by side?
Here is the code:
css:
<style type="text/css">
#left_div
{
float: left;
width: 250px;
height: 400px;
border: solid 1px red;
}
#right_div
{
width: 3000px;
border: solid 1px blue;
}
</style>
html:
<div id="left_div">
text in left_div
</div>
<div id="right_div">
text in right_div
</div>
Add float: left to the right_div as well.
If it is anything similar to the examples shown by Matthew James Taylor and his Perfect 2 Column Left Menu take a look at how he is doing it and maybe copy it!
IE has in the past also had the issue that it took height and width to mean height-min and width-min, thus still allowing boxes to resize eventhough they had specific limits set. See Webcredible's article, most notably number 2 on their list!
You can also add a left margin of at least 250px (the width of the left_div) to the right_div, that way there will always be space for the left_div next to the right_div.
change the doctype: (IE8 needs it to render correctly the webpage)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd " > <html xmlns="h t t p://w w w.w3.org/1999/xhtml" xml:lang="en-GB">
(I edited the urls with whitespaces so don't forget remove them :) )

Resources