Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-13-2010, 04:39 PM   PM User | #1
haithamedrees23
New Coder

 
Join Date: Dec 2010
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
haithamedrees23 is an unknown quantity at this point
li doesn't expanded

i have 2 li and each of them should hold 2 right floated divs , but the are not expanded to hold the divs properly as shown in the screenshot in the url below



the HTML code is
Code:
<div class="anothernews">
<ul>

<li><div><img src="Images/smallimg.jpg" /> </div>
<div><p><a href="#">4221 حالة إصابة مكتشفة بالإيدز فى مصر   
</a></p></div>
<div class="clear"></div>
</li>


<li><div><img src="Images/smallimg.jpg" /> </div>
<div><p><a href="#">4221 حالة إصابة م
كتشفة بالإيدز فى مصر   
</a></p></div>
<div class="clear"></div>
</li>

<div class="clear"></div>
</ul>
<div class="clear"></div>
</div><!--end of anothernews div-->


The CSS code
Code:
.anothernews{ width:230px; float:right; margin-right:15px}

.anothernews  li{  list-style:none; width:100%; border:1px solid #000000; height:100%;}
.anothernews li div{ float:right; width:48% }
.anothernews li div+div{ margin-right:8px}
haithamedrees23 is offline   Reply With Quote
Old 12-13-2010, 04:40 PM   PM User | #2
haithamedrees23
New Coder

 
Join Date: Dec 2010
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
haithamedrees23 is an unknown quantity at this point
i have attached the file
Attached Thumbnails
Click image for larger version

Name:	li issue.jpg
Views:	28
Size:	38.3 KB
ID:	9192  
haithamedrees23 is offline   Reply With Quote
Old 12-13-2010, 05:30 PM   PM User | #3
paolo1
New Coder

 
Join Date: Dec 2010
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
paolo1 is an unknown quantity at this point
I can't understand what is wrong. I've tested your code and divs are shown, picture and link in both li items.
paolo1 is offline   Reply With Quote
Old 12-13-2010, 05:49 PM   PM User | #4
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Hello haithamedrees23,
You can't put divs inside your li's. Check your code with the validator.

See the links about validation in my signature line below.

W3schools has this about lists.
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Old 12-14-2010, 10:03 AM   PM User | #5
Dormilich
Senior Coder

 
Dormilich's Avatar
 
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,908
Thanks: 10
Thanked 293 Times in 289 Posts
Dormilich is on a distinguished road
Quote:
Originally Posted by Excavator View Post
You can't put divs inside your li's.
really? the DTD doesn’t forbid that.
__________________
please post your code wrapped in [CODE] [/CODE] tags
Dormilich is offline   Reply With Quote
Old 12-14-2010, 10:41 AM   PM User | #6
SB65
Senior Coder

 
Join Date: Feb 2009
Location: West Yorkshire
Posts: 2,827
Thanks: 9
Thanked 685 Times in 679 Posts
SB65 will become famous soon enoughSB65 will become famous soon enough
You haven't posted your whole code here, but I suspect the issue is with your .clear divs. If you have:

Code:
.clear{clear:both}
then this div:

Code:
<li><div><img src="Images/smallimg.jpg" /> </div>
<div><p><a href="#">4221 حالة إصابة مكتشفة بالإيدز فى مصر   
</a></p></div>
<div class="clear"></div>
</li>
gets clear:both from the css at the top, but also inherits float:right from:

Code:
.anothernews li div {
    float: right;
    width: 48%;
}
So the clearing div is in itself floated and consequently doesn't clear the float. Making the clear div:

Code:
.clear{clear:both;float:none!important}
fixes the issue. If this doesn't fix it, then we need to see all your code, or preferably a link to your page.

(The validator allows a div within an li, but not one as a direct child of a ul)
SB65 is offline   Reply With Quote
Old 12-14-2010, 11:28 AM   PM User | #7
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Quote:
Originally Posted by Dormilich View Post
really? the DTD doesn’t forbid that.
Who knew? It is valid. I'm looking for a semantic use for that now...
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Old 12-14-2010, 12:18 PM   PM User | #8
haithamedrees23
New Coder

 
Join Date: Dec 2010
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
haithamedrees23 is an unknown quantity at this point
hello SB65

thanks a million , your solution fixed the problem , but why i should add !important?


also thank you all for your efforts, really appreciate
haithamedrees23 is offline   Reply With Quote
Old 12-14-2010, 12:30 PM   PM User | #9
SB65
Senior Coder

 
Join Date: Feb 2009
Location: West Yorkshire
Posts: 2,827
Thanks: 9
Thanked 685 Times in 679 Posts
SB65 will become famous soon enoughSB65 will become famous soon enough
Without the !important, the float will remain since .anothernews li div as a selector is more specific than .clear. Adding !important ensures that the float:none in .clear css takes precedence.

Incidentally, you can see this in Firebug if you look at the css applied to that div.

Last edited by SB65; 12-14-2010 at 12:33 PM..
SB65 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:33 PM.


Advertisement
Log in to turn off these ads.