TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-24-2009, 01:56 PM   #1 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default Help with CSS on IE

Heya!

I'm currently developing a website for my dad, and I've only done the "ground" as of now. Looks like this: http://adolflemons.se/beta/

It works great in FireFox. But if you view it in Internet Explorer 7, it looks weird. Any idea how to fix it?
__________________
Tanax is offline  
Reply With Quote
Old 05-24-2009, 02:44 PM   #2 (permalink)
The Contributor
 
Join Date: Nov 2008
Location: Sweden
Posts: 36
Thanks: 1
hjalmar is on a distinguished road
Default

Can you please post a screenshot of what is wrong or atleast point us to the right direction, I'm only running IE6 and that doesn't support child-selectors.

selector > selector1...
hjalmar is offline  
Reply With Quote
Old 05-24-2009, 03:42 PM   #3 (permalink)
The Addict
 
CoryMathews's Avatar
 
Join Date: Nov 2007
Location: USA
Posts: 256
Thanks: 7
CoryMathews is on a distinguished road
Default

What?!

First off why is it split into 4 different sheets?

Second why so many >? thats just making it harder on you, get rid of them just use normal #id selectors.

third a width of 1380px. You just cut out more then half the world. We all have to side scroll now. make it 960px.

and it looks the same in IE7 as the rest so I don't see what the problem is.
CoryMathews is offline  
Reply With Quote
Old 05-24-2009, 03:56 PM   #4 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Quote:
Originally Posted by CoryMathews View Post
What?!

First off why is it split into 4 different sheets?

Second why so many >? thats just making it harder on you, get rid of them just use normal #id selectors.
Thanks, I noticed this myself and I wasn't sure why so I didn't say anything since I'm no CSS expert.


Quote:
Originally Posted by CoryMathews View Post
third a width of 1380px. You just cut out more then half the world. We all have to side scroll now. make it 960px.
Yeah I had to scroll too and I'm using a 1080p monitor. Of course if I stretched it all the way out I wouldn't, but most of the time my brower uses about 75% width of the monitor. Being a 1080p monitor, that's all I need it to do...

Quote:
Originally Posted by CoryMathews View Post
and it looks the same in IE7 as the rest so I don't see what the problem is.
For me, IE7 is messed up. If you look at the middle layers. The red,blue and purple boxes collide with the top boxes.
In FF, they are all evenly spaced out...
allworknoplay is offline  
Reply With Quote
Old 05-24-2009, 07:11 PM   #5 (permalink)
The Acquainted
 
Randy's Avatar
 
Join Date: May 2007
Location: Your G/F's Closet
Posts: 114
Thanks: 7
Randy is on a distinguished road
Default

Use this site to read up on IE CSS Hacks:
http://www.positioniseverything.net/...-dehacker.html

then I am assuming by what allworknoplay said it is your "float" that is having issues so i recommend play with that.

I do not have IE7 so I am unable to look myself.
__________________
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25 - Andrew Rutherford
Send a message via AIM to Randy Send a message via MSN to Randy
Randy is offline  
Reply With Quote
The Following User Says Thank You to Randy For This Useful Post:
Tanax (05-25-2009)
Old 05-24-2009, 09:02 PM   #6 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Quote:
Originally Posted by hjalmar View Post
Can you please post a screenshot of what is wrong or atleast point us to the right direction, I'm only running IE6 and that doesn't support child-selectors.

selector > selector1...
Sure, I'll upload a pic soon!

Quote:
Originally Posted by CoryMathews View Post
What?!

First off why is it split into 4 different sheets?

Second why so many >? thats just making it harder on you, get rid of them just use normal #id selectors.

third a width of 1380px. You just cut out more then half the world. We all have to side scroll now. make it 960px.

and it looks the same in IE7 as the rest so I don't see what the problem is.
Well, I just don't like the idea of having a 1000-line CSS-document where everything's just bloated. Easier to find this way as the "main.css" is referring to all styling of the "main"(which contains left - menu, center - content, right - loginbox and stuff). Is it affecting the loading-time or usability by splitting them up?

Alright then! I'll do that.

Really? I didn't have to scroll anything :o
Perhaps I have a smaller resolution. I'm on a 15" screen so it's not like I have a big screen. But my resolution could be smaller than yours. When I have 1380px in width, the width is stretched so it has 10px margin (white space) before the browser window borders. See screenshot of how it looks to me.

And it's not really the same in IE7 and FF, see allworknoplay's reply.

Quote:
Originally Posted by allworknoplay View Post
For me, IE7 is messed up. If you look at the middle layers. The red,blue and purple boxes collide with the top boxes.
In FF, they are all evenly spaced out...
That's exactly what I mean!

Quote:
Originally Posted by Randy View Post
Use this site to read up on IE CSS Hacks:
http://www.positioniseverything.net/...-dehacker.html

then I am assuming by what allworknoplay said it is your "float" that is having issues so i recommend play with that.

I do not have IE7 so I am unable to look myself.
I will post a screenshot. Thank you very much for the link, I will definitely check that out!
__________________
Tanax is offline  
Reply With Quote
Old 05-24-2009, 09:09 PM   #7 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Here's the images.

FireFox(how it should look):

IE7(how it should NOT look):


Also note the FireFox, I do not have a scrollbar, but in IE7 I have.. so the width is weirdly displayed in IE7. Apparently I need to lower the width.
But you still see the problems I have with IE7.
__________________
Tanax is offline  
Reply With Quote
Old 05-24-2009, 10:14 PM   #8 (permalink)
The Contributor
 
Join Date: Nov 2008
Location: Sweden
Posts: 36
Thanks: 1
hjalmar is on a distinguished road
Default

First of all this doesn't seem to complex to be using any child selectors, you really need to change behaviour for an element that belongs to different parents? and then it works in IE6 aswell. :)

descendant selectors works fine, also take note for specificity. selector selector2 vs selector#id selector. But this is simple enought so shouldn't be any problem right now :)

First of sort out all the different height definitions, #head = 150px, #logo = 160px(padding) and #header = 200px as floats don't take up any space.

No need for a clearing div as your main content is in a wrapper, clear the floats there.

Use good names :) left right center etc doesn't really mean anything. You can also import other stylesheets in another stylesheet document like @import url("style.css"); (depending on how you import it there is various support for old browsers, so importing styles like this you exlude browser that don't fully support css2 anyways) remember though that it has to be before anything else in that document except comments.

And to easy up some coding bugs, try to use padding on parent elements instead of margings, that will save you a shitloads with the double margin bugs in IE6 :D

Got a bit off-topic with random rambling but, look over your height definitions or make the parent autoclear(hint: floats clear floats, or use a hack for it ) or clear it inside where the floats are.

Cheers hjalmar
hjalmar is offline  
Reply With Quote
The Following User Says Thank You to hjalmar For This Useful Post:
Tanax (05-25-2009)
Old 05-25-2009, 04:51 AM   #9 (permalink)
The Addict
 
CoryMathews's Avatar
 
Join Date: Nov 2007
Location: USA
Posts: 256
Thanks: 7
CoryMathews is on a distinguished road
Default

Sorry forgot win7 has ie8 not ie7.. that would be why it looks the same.

Quote:
Is it affecting the loading-time or usability by splitting them up?
Yes 4 html calls instead of 1, but for now it does not matter.


The actual size of your screen (15 inch, 17inch w/e) does not matter, its your screen resolution. You seem to be running 1440x900 (my guess) but most of the world still runs below this. (http://www.w3counter.com/globalstats.php)

The easiest fix (but not the best) is to do a conditional style sheet for ie7 and lower. this way you could just add padding to that header id and it should be fine.

Do not use css hacks an mentioned above, they will only piss you off later, and they scream css noob to anyone who known anything about css.
CoryMathews is offline  
Reply With Quote
The Following User Says Thank You to CoryMathews For This Useful Post:
Tanax (05-25-2009)
Old 05-25-2009, 11:51 AM   #10 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Quote:
Originally Posted by hjalmar View Post
First of all this doesn't seem to complex to be using any child selectors, you really need to change behaviour for an element that belongs to different parents? and then it works in IE6 aswell. :)

descendant selectors works fine, also take note for specificity. selector selector2 vs selector#id selector. But this is simple enought so shouldn't be any problem right now :)

First of sort out all the different height definitions, #head = 150px, #logo = 160px(padding) and #header = 200px as floats don't take up any space.

No need for a clearing div as your main content is in a wrapper, clear the floats there.

Use good names :) left right center etc doesn't really mean anything. You can also import other stylesheets in another stylesheet document like @import url("style.css"); (depending on how you import it there is various support for old browsers, so importing styles like this you exlude browser that don't fully support css2 anyways) remember though that it has to be before anything else in that document except comments.

And to easy up some coding bugs, try to use padding on parent elements instead of margings, that will save you a shitloads with the double margin bugs in IE6 :D

Got a bit off-topic with random rambling but, look over your height definitions or make the parent autoclear(hint: floats clear floats, or use a hack for it ) or clear it inside where the floats are.

Cheers hjalmar
No not really.. so I've removed all the > in the CSS, but I doubt it'll work for IE6 xD

Ye, in my conditional stylesheet for ie7, I've set
Code:
div#head div#header {

	height: 160px;

}
instead of the height: 200px that were set in the regular CSS-doc. It fixed the #header-part. But the content is still "overlapping" the #head.

I didn't understand the part about clearing div.. if I put the clear:both inside #main, it won't work =/

About padding, I'm going to fix that later! Right now I just want it to look the same in IE7 as it does in FF.

I'm really a newbie when it comes to CSS, as you probably noticed when looking over the code, so I have really no idea how to solve this, even if you specifically say "making parents autoclear" (I'm like wtf? ).

Quote:
Originally Posted by CoryMathews View Post
Sorry forgot win7 has ie8 not ie7.. that would be why it looks the same.



Yes 4 html calls instead of 1, but for now it does not matter.


The actual size of your screen (15 inch, 17inch w/e) does not matter, its your screen resolution. You seem to be running 1440x900 (my guess) but most of the world still runs below this. (http://www.w3counter.com/globalstats.php)

The easiest fix (but not the best) is to do a conditional style sheet for ie7 and lower. this way you could just add padding to that header id and it should be fine.

Do not use css hacks an mentioned above, they will only piss you off later, and they scream css noob to anyone who known anything about css.
I'll probably change it when I'm done with the basic CSS.
Ye, I figured. I changed the width to 960px now.

Adding padding to the #header did not solve it.
I'm not really sure exactly what I did, but right now I got height set to 200px in my regular CSS, and in my iefix CSS I got nothing, but the height of the #header still is correct according to the logo.

But the content is still overlapping.

I'm sorry if you guys already said a solution here that would work. I'm just really.. newbie with CSS so I don't really know exactly what to do with all these(great) suggestions that you give me.

I've uploaded the newest update of the layout here:
http://www.adolflemons.se/beta/

And here's 2 new screenshots for those of you who don't have IE7:

__________________
Tanax is offline  
Reply With Quote
Old 05-25-2009, 07:29 PM   #11 (permalink)
The Contributor
 
Join Date: Nov 2008
Location: Sweden
Posts: 36
Thanks: 1
hjalmar is on a distinguished road
Default

Quote:
Originally Posted by Tanax View Post
No not really.. so I've removed all the > in the CSS, but I doubt it'll work for IE6 xD

Ye, in my conditional stylesheet for ie7, I've set
Code:
div#head div#header {

	height: 160px;

}
instead of the height: 200px that were set in the regular CSS-doc. It fixed the #header-part. But the content is still "overlapping" the #head.

I didn't understand the part about clearing div.. if I put the clear:both inside #main, it won't work =/

About padding, I'm going to fix that later! Right now I just want it to look the same in IE7 as it does in FF.

I'm really a newbie when it comes to CSS, as you probably noticed when looking over the code, so I have really no idea how to solve this, even if you specifically say "making parents autoclear" (I'm like wtf? ).



I'll probably change it when I'm done with the basic CSS.
Ye, I figured. I changed the width to 960px now.

Adding padding to the #header did not solve it.
I'm not really sure exactly what I did, but right now I got height set to 200px in my regular CSS, and in my iefix CSS I got nothing, but the height of the #header still is correct according to the logo.

But the content is still overlapping.

I'm sorry if you guys already said a solution here that would work. I'm just really.. newbie with CSS so I don't really know exactly what to do with all these(great) suggestions that you give me.
It helps using selectors that IE6 supports atleast :D

I'll keep it simple this time, from your #head{} remove the height. and add overflow: auto; what do you get?

And get rid of that conditional comment for IE it's not needed here.
hjalmar is offline  
Reply With Quote
The Following User Says Thank You to hjalmar For This Useful Post:
Tanax (05-25-2009)
Old 05-25-2009, 10:19 PM   #12 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Well that's good

Holy shit. That actually did it!


I removed the conditional comment for IE aswell. Haven't uploaded this update on the live server yet though, so I can only show you that SS.

One thing left though, just a small thing. If you check this last SS, and compare the font-weight to the previously posted Firefox SS, you'll see it's much more thicker in IE, why is that? What's causing it, and how to fix?

Also, if you have time, and you want, could you explain how the overflow: auto, made it work?? And why I had to remove the height from #head ?

Thanks a bunch!
__________________
Tanax is offline  
Reply With Quote
Old 05-25-2009, 10:22 PM   #13 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

By the way, how does it look in IE6 now?
__________________
Tanax is offline  
Reply With Quote
Old 05-25-2009, 10:43 PM   #14 (permalink)
The Contributor
 
Join Date: Nov 2008
Location: Sweden
Posts: 36
Thanks: 1
hjalmar is on a distinguished road
Default

Quote:
Originally Posted by Tanax View Post
Well that's good

Holy shit. That actually did it!


I removed the conditional comment for IE aswell. Haven't uploaded this update on the live server yet though, so I can only show you that SS.

One thing left though, just a small thing. If you check this last SS, and compare the font-weight to the previously posted Firefox SS, you'll see it's much more thicker in IE, why is that? What's causing it, and how to fix?

Also, if you have time, and you want, could you explain how the overflow: auto, made it work?? And why I had to remove the height from #head ?

Thanks a bunch!
** IGNORE **
What i would assume is because you are using 100% font-size on your body. Now the browsers have their default values that varies so it could be that.
** /IGNORE **

Looks the same for me in ff3 and your screenshots, aswell in safari.

There is a neat little trick that lots of people use and it's to set the body font-size: 62.5%; and that would equal 1em to around 10px but still be scalable.

Could be a bit tricky using em's at first tho as it's relative to it's parent(s).

Because you don't need a height defined, you want it to autowrap around your content, overflow: auto; does just that(not neccessarely(sp?) what it's intended for but it works like that also ), you having a height there would prob get you some scrollbars as your height was less then whats inside. your clearing div would have worked aswell if it was inside the wrapper without a height defined on #head{} (do whats best for you, on some occasions you could still end up with scrollbars when using overflow for autoclearing)

Don't have access to a pc/bootcamp/parralels etc right now :/, so hopefully someone else can help you out with IE6.

No problemo!

Hjalmar

*edit*
Don't use names like this, class="sub 2" thats actually 2 different classes it's looking for, .sub{} and .2{} (actually not even valid).

nono: 2sub (starting with a number)
yesyes: sub-2, sub2 (ending with a number is just fine)

Last edited by hjalmar : 05-25-2009 at 11:19 PM.
hjalmar is offline  
Reply With Quote
Old 05-26-2009, 07:02 AM   #15 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Quote:
Originally Posted by hjalmar View Post
** IGNORE **
What i would assume is because you are using 100% font-size on your body. Now the browsers have their default values that varies so it could be that.
** /IGNORE **

Looks the same for me in ff3 and your screenshots, aswell in safari.

There is a neat little trick that lots of people use and it's to set the body font-size: 62.5%; and that would equal 1em to around 10px but still be scalable.

Could be a bit tricky using em's at first tho as it's relative to it's parent(s).

Because you don't need a height defined, you want it to autowrap around your content, overflow: auto; does just that(not neccessarely(sp?) what it's intended for but it works like that also ), you having a height there would prob get you some scrollbars as your height was less then whats inside. your clearing div would have worked aswell if it was inside the wrapper without a height defined on #head{} (do whats best for you, on some occasions you could still end up with scrollbars when using overflow for autoclearing)

Don't have access to a pc/bootcamp/parralels etc right now :/, so hopefully someone else can help you out with IE6.

No problemo!

Hjalmar

*edit*
Don't use names like this, class="sub 2" thats actually 2 different classes it's looking for, .sub{} and .2{} (actually not even valid).

nono: 2sub (starting with a number)
yesyes: sub-2, sub2 (ending with a number is just fine)
Ah, now that you say it it's probably possible that it's like that. I'll try experiment with it. As I said, it's just a minor detail.

And yes, em's is tricky, but I'll try

Oh, I see! And about the clearing div, you meant it like this?

HTML Code:
<div id="head">
<div id="logo">..</div>
<div id="header">..</div>
<div class="clear"></div>
</div>

<div id="main">
...
instead of

HTML Code:
<div id="head">
<div id="logo">..</div>
<div id="header">..</div>
</div>

<div class="clear"></div>

<div id="main">
...
??

Ye I was actually very uncertain about that, but I'll edit it!

Thanks for all the help mate!
__________________
Tanax is offline  
Reply With Quote
Old 05-26-2009, 07:21 AM   #16 (permalink)
The Contributor
 
Join Date: Nov 2008
Location: Sweden
Posts: 36
Thanks: 1
hjalmar is on a distinguished road
Default

Exactly! as floated elements don't take up any space(taken out of the normal flow...) so your wrapper/container div #head in this case won't act like it has something in it and wont expand with the flow.

So you clearing the floated element inside would have solved the problem. And you don't have to hard code everything(height in this case) it will just be more code and annoying edits in the end (if there will be any :D)

Block elements take up 100% of the given width, except for floats that will wrap down to the content inside. So if you are aiming for 100% just leave it out much easier and less code if dealing with padding aswell. But i assume you did know that.

I'm just adding on with some rambling someone else might find usefull. :)
hjalmar is offline  
Reply With Quote
Old 05-31-2009, 11:07 AM   #17 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

I see!
Thank you

Your rambling is good, I find it very interesting and useful information to learn
__________________
Tanax is offline  
Reply With Quote
Old 05-31-2009, 02:14 PM   #18 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

I have a quick question about DIV's.

I have a main body container that has a fixed width of 1024. And the minimal height is 350 px.

The reason for the min height is that I want all pages to have a consistent look, even if there's not much content.

But when the content exceeds the 350 px, the content just flows passed the DIV container.

Is is possible for the DIV container to have the DIV stretch beyond the 350 px if the content is a lot?

Basically the same way that tables would handle it?
allworknoplay is offline  
Reply With Quote
Old 05-31-2009, 03:36 PM   #19 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

If the div is floated, then the container won't be stretched, unless you add a clear div like I did.

HTML Code:
<div id="container">
<div>
Your content..
</div>

<div class="clear"></div>
</div>
And the css:
.clear { clear: both; }
__________________
Tanax is offline  
Reply With Quote
Old 05-31-2009, 03:49 PM   #20 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Quote:
Originally Posted by Tanax View Post
If the div is floated, then the container won't be stretched, unless you add a clear div like I did.

HTML Code:
<div id="container">
<div>
Your content..
</div>

<div class="clear"></div>
</div>
And the css:
.clear { clear: both; }
Thanks Tanax, I will give that a shot....
allworknoplay is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:12 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design