473,386 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Getting a div to clear only 1 of 2 left-floated elements

helimeef
Hi, I am working on a fake little product page where it shows a list of products, and for each product it shows its name, a picture of it, a description, and the rating.

I uploaded the page to my clients server (shhh) here,
and here is a screenshot.

Now as you can see from the page, the description wraps around the product name and info, but I cannot do "clear: both" or "clear: left" for the description div because it will clear the image too. Is there any way to get the text to drop down past the name but not the image?

Thanks in advanced,
helimeef

P.S. the CSS is kind of messy because I haven't optimized it yet.
Dec 18 '07 #1
4 1592
drhowarddrfine
7,435 Expert 4TB
I don't think you need all that:
[HTML]<body>

<img src="office.jpg" class="rating">
<img src="products_files/rifle_small.png" style="float:left">
<h1>Crosman Soft Air SWAT Kit</h1>
<p style="float:left"><span class="price">$74.99</span><span class="available">2 in stock at nearest store (Oldsmar, FL)</span></p>

<p style="clear:both">
The Crosman Soft Air SWAT kit is great for beginner airsofters who want a
stable gun while being stealthy and powerful at the same time. The
shotgun-like rifle included has great impact and can take out multiple
players at once, and the pistol pulls through as your last resort if
you run out of ammo. Also includes goggles, 4,000 .2 gram BBs, a spare
magazine, and a removable stock.
</p>

<div class="extender"></div>
</body></html>[/HTML]
btw, I used to run the largest airsoft game in the Midwest. "The Art of War"
Dec 19 '07 #2
I don't think you need all that:
[HTML]<body>

<img src="office.jpg" class="rating">
<img src="products_files/rifle_small.png" style="float:left">
<h1>Crosman Soft Air SWAT Kit</h1>
<p style="float:left"><span class="price">$74.99</span><span class="available">2 in stock at nearest store (Oldsmar, FL)</span></p>

<p style="clear:both">
The Crosman Soft Air SWAT kit is great for beginner airsofters who want a
stable gun while being stealthy and powerful at the same time. The
shotgun-like rifle included has great impact and can take out multiple
players at once, and the pistol pulls through as your last resort if
you run out of ammo. Also includes goggles, 4,000 .2 gram BBs, a spare
magazine, and a removable stock.
</p>

<div class="extender"></div>
</body></html>[/HTML]
btw, I used to run the largest airsoft game in the Midwest. "The Art of War"
Well when I do that, it clears the image too. I want the description to be up against the name and other info.
Thanks for the help though, this gave me the idea to redo my code and make it cleaner. Hopefully I can fix it after I do that.

Heres what I came up with:
Expand|Select|Wrap|Line Numbers
  1. <div class="product">
  2. <img src="/rifle_small.png" />
  3.  
  4. <div class="prod_info">
  5. <h1>Crosman Soft Air SWAT Kit <span>$74.99</span></h1>
  6. <p>The Crosman Soft Air SWAT kit is great for beginner airsofters who want a stable gun while being stealthy and powerful at the same time. The shotgun-like rifle included has great impact and can take out multiple players at once, and the pistol pulls through as your last resort if you run out of ammo. Also includes goggles, 4,000 .2 gram BBs, a spare magazine, and a removable stock.</p>
  7. </div>
  8.  
  9. <div class="extender"></div>
  10. </div>
  11.  
and the new and improved CSS:

Expand|Select|Wrap|Line Numbers
  1. body {
  2.     font: 1em Arial, Helvetica, sans-serif;
  3.     padding: 1em;
  4.     color: #333;
  5. }
  6. .product {
  7.     margin: 1em;
  8.     font-size: .8em;
  9.     border: 1px solid #aaa;
  10.     padding: 1.5em;
  11. }
  12. .product img {
  13.     float: left;
  14. }
  15. .product .h1 {
  16.     display: inline;
  17. }
  18. .product h1 span {
  19.     font-size: .6em;
  20.     color: #aaa;
  21.     vertical-align: text-top;
  22. }
  23. .product .prod_info {
  24.     margin-left: 1em;
  25. }
  26.  
  27. /* Make sure product wrapper reaches extends past floated divs */
  28. .product .extender {
  29.     clear: both;
  30.     visibility: hidden;
  31. }
  32.  
However the margin-left on the .product .prod_info does not seem to do anything. I set it to 80em and it moved a lot. I'm not sure what's wrong. margin-top works. I used the current element outline in the web developer toolbar addon for firefox, and I still can't find out what's causing this.

Please help
Thank you.

BTW I am looking around for a new airsoft rifle, full auto with a red dot sight, do you know any good dealers/guns on the web?

Thanks again :)
Dec 19 '07 #3
drhowarddrfine
7,435 Expert 4TB
Idon'tknow what I did last night but I just flew in from Chicago and boy are my arms tired.

Play with this:
[HTML] <div>
<img src="../office.jpg" style="height:18px;width:50px;float:right">
<img src="../products_files/rifle_small.png" style="float:left">
<div style="margin:0 auto;width:80%">
<h1>Crosman Soft Air SWAT Kit</h1>
<p><span class="price">$74.99</span><span class="available">2 in stock at nearest store (Oldsmar, FL)</span></p>
</div>

<p>
The Crosman Soft Air SWAT kit is great for beginner airsofters who want a
stable gun while being stealthy and powerful at the same time. The
shotgun-like rifle included has great impact and can take out multiple
players at once, and the pistol pulls through as your last resort if
you run out of ammo. Also includes goggles, 4,000 .2 gram BBs, a spare
magazine, and a removable stock.
</p>

</div> [/HTML]

Even though we still own some airsoft gear, I'm not into it anymore and don't even have my dealer links anymore.
Dec 19 '07 #4
Idon'tknow what I did last night but I just flew in from Chicago and boy are my arms tired.

Play with this:
[HTML] <div>
<img src="../office.jpg" style="height:18px;width:50px;float:right">
<img src="../products_files/rifle_small.png" style="float:left">
<div style="margin:0 auto;width:80%">
<h1>Crosman Soft Air SWAT Kit</h1>
<p><span class="price">$74.99</span><span class="available">2 in stock at nearest store (Oldsmar, FL)</span></p>
</div>

<p>
The Crosman Soft Air SWAT kit is great for beginner airsofters who want a
stable gun while being stealthy and powerful at the same time. The
shotgun-like rifle included has great impact and can take out multiple
players at once, and the pistol pulls through as your last resort if
you run out of ammo. Also includes goggles, 4,000 .2 gram BBs, a spare
magazine, and a removable stock.
</p>

</div> [/HTML]

Even though we still own some airsoft gear, I'm not into it anymore and don't even have my dealer links anymore.
Thanks!
too bad about the airsoft thing though :(
Dec 19 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: middletree | last post by:
How do I request the actual page name that I'm on? This is going to go into an include file, and depending on which page I'm on, I'd like to do different things. I'm looking for "pagename.asp"
0
by: Olly | last post by:
I am using the following pure css layout with a header and footer: http://www.fu2k.org/alex/css/layouts/3Col_NN4_FMFM.mhtml The left column floats to the left of the main content (middle...
4
by: Florian Brucker | last post by:
Hi! I've got a problem with float & clear. Take this example code: <div style=" width:100px; height:100px; background-color:#FF0000; float:left; margin:10px;"></div> <span...
1
by: Pau Roldan | last post by:
Hi, sorry if this has been asked previously, but I couldn't find a suitable answer in previous posts. Here is a sample page illustrating the problem:...
2
by: Alex | last post by:
Hi all, I'm writing a small web application which searches a database based on a date field, and populates a datagrid control with the results. The datagrid control has selection buttons added...
1
by: laurakr | last post by:
I am trying to use a clear to get my bottom nav bar below the quote box on the right, but it isn't working. I would like the bottom edge of the quote box to "stick" to the footer nav bar but copy...
1
by: simbarashe | last post by:
Hie could someone please help me with getting and using the current page url. I have a function that gets the url, I want to use it with header(location : XXX) but it wont work. The code is as...
7
by: bugmenot | last post by:
So I want to get some text from a web page and get it to show up in my program. Here's the part that has what I want: <div style="float: right; clear: right; background: #1daa42; color: #FFF;...
2
bugboy
by: bugboy | last post by:
I'm building an interface like "column view" on a mac. I have nested <div> columns inside another <div> container which is set to 57% width of page. The nested div's act as columns which are...
7
vikas251074
by: vikas251074 | last post by:
I am getting error above in following code since few days giving tension day and night. How can I solve this? I am facing since Oct.25. in line no. 362 After doing a lot of homework, I am...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.