Why aren't my floats lining up? - css

I've been staring at this problem for awhile now, and I was hoping someone on here could steer me in the right direction
For some reason I can't get my floats to line up the way i want them to! I managed to get the movie to the right, but when I want the two floated columns of reviewer's quotes to be up there right next to it.
Here's my CSS Code that deals with the picture and the columns
.overview { /* The picture */
display:block;
float:right;
background-color: #A2B964;
}
.column1{
clear: left;
width: 31%;
margin-left: 2%;
margin-right: 1%;
}
.column2{
clear: left;
width: 31%;
margin-left: 1%;
margin-right: 2%;
}
Here is the HTML for the picture:
<div class = "overview">
<img src="http://www.cs.washington.edu/education/courses/cse190m/12sp/homework/2/overview.png" alt="general overview" />
</div>
And the HTML for the columns:
<div class = "column1">
<p class = "quotebox">
<img src="http://www.cs.washington.edu/education/courses/cse190m/12sp/homework/2/rotten.gif" alt="Rotten" style="float:left;padding:5px;"/>
<q>Ditching the cheeky, self-aware wink that helped to excuse the concept's inherent corniness, the movie attempts to look polished and 'cool,' but the been-there animation can't compete with the then-cutting-edge puppetry of the 1990 live-action movie.</q>
</p>
<p class = "reviewer">
<img src="http://www.cs.washington.edu/education/courses/cse190m/12sp/homework/2/critic.gif" alt="Critic" style="float:left;padding:5px;"/>
Peter Debruge <br />
<em>Variety</em>
</p>
<p class = "quotebox">
<img src="http://www.cs.washington.edu/education/courses/cse190m/12sp/homework/2/fresh.gif" alt="Fresh" style="float:left;padding:5px;"/>
<q>TMNT is a fun, action-filled adventure that will satisfy longtime fans and generate a legion of new ones.</q>
</p>
<p class = "reviewer">
<img src="http://www.cs.washington.edu/education/courses/cse190m/12sp/homework/2/critic.gif" alt="Critic" style="float:left;padding:5px;"/>
Todd Gilchrist <br />
<em>IGN Movies</em>
</p>
<p class = "quotebox">
<img src="http://www.cs.washington.edu/education/courses/cse190m/12sp/homework/2/rotten.gif" alt="Rotten" style="float:left;padding:5px;"/>
<q>It stinks!</q>
<br />
</p>
<p class = "reviewer">
<img src="http://www.cs.washington.edu/education/courses/cse190m/12sp/homework/2/critic.gif" alt="Critic" style="float:left;padding:5px;"/>
Jay Sherman (unemployed)
</p>
<p class = "quotebox">
<img src="http://www.cs.washington.edu/education/courses/cse190m/12sp/homework/2/rotten.gif" alt="Rotten" style="float:left; padding:5px;"/>
<q>The rubber suits are gone and they've been redone with fancy computer technology, but that hasn't stopped them from becoming dull.</q>
</p>
<p class = "reviewer">
<img src="http://www.cs.washington.edu/education/courses/cse190m/12sp/homework/2/critic.gif" alt="Critic" style="float:left;padding:5px;"/>
Joshua Tyler <br />
<em>CinemaBlend.com</em>
</p>
<p class = "quotebox">
<img src="http://www.cs.washington.edu/education/courses/cse190m/12sp/homework/2/rotten.gif" alt="Rotten" style="float:left;padding:5px;"/>
<q>YOUR REVIEW HERE</q>
</p>
<p class = "reviewer">
<img src="http://www.cs.washington.edu/education/courses/cse190m/12sp/homework/2/critic.gif" alt="Critic" style="float:left;padding:5px;"/>
NAME <br />
<em>PUBLICATION</em>
</p>
</div>
<div class = "column2">
<p class = "quotebox">
<img src="http://www.cs.washington.edu/education/courses/cse190m/12sp/homework/2/rotten.gif" alt="Rotten" style="float:left;padding:5px;"/>
<q>The turtles themselves may look prettier, but are no smarter; torn irreparably from their countercultural roots, our superheroes on the half shell have been firmly co-opted by the industry their creators once sought to spoof.</q>
</p>
<p class = "reviewer">
<img src="http://www.cs.washington.edu/education/courses/cse190m/12sp/homework/2/critic.gif" alt="Critic" style="float:left;padding:5px;"/>
Jeannette Catsoulis <br />
<em>New York Times</em>
</p>
<p class = "quotebox">
<img src="http://www.cs.washington.edu/education/courses/cse190m/12sp/homework/2/rotten.gif" alt="Rotten" style="float:left;padding:5px;"/>
<q>Impersonally animated and arbitrarily plotted, the story appears to have been made up as the filmmakers went along.</q>
</p>
<p class = "reviewer">
<img src="http://www.cs.washington.edu/education/courses/cse190m/12sp/homework/2/critic.gif" alt="Critic" style="float:left;padding:5px;"/>
Ed Gonzalez <br />
<em>Slant Magazine</em>
</p>
<p class = "quotebox">
<img src="http://www.cs.washington.edu/education/courses/cse190m/12sp/homework/2/fresh.gif" alt="Fresh" style="float:left;padding:5px;"/>
<q>The striking use of image and motion allows each sequence to leave an impression. It's an accomplished restart to this franchise.</q>
</p>
<p class = "reviewer">
<img src="http://www.cs.washington.edu/education/courses/cse190m/12sp/homework/2/critic.gif" alt="Critic" style="float:left;padding:5px;"/>
Mark Palermo <br />
<em>Coast (Halifax, Nova Scotia)</em>
</p>
<p class = "quotebox">
<img src="http://www.cs.washington.edu/education/courses/cse190m/12sp/homework/2/rotten.gif" alt="Rotten" style="float:left;padding:5px;"/>
<q>The script feels like it was computer generated. This mechanical presentation lacks the cheesy charm of the three live action films.</q>
</p>
<p class = "reviewer">
<img src="http://www.cs.washington.edu/education/courses/cse190m/12sp/homework/2/critic.gif" alt="Critic" style="float:left;padding:5px;"/>
Steve Rhodes <br />
<em>Internet Reviews</em>
</p>
<p class = "quotebox">
<img src="http://www.cs.washington.edu/education/courses/cse190m/12sp/homework/2/rotten.gif" alt="Rotten" style="float:left;padding:5px;"/>
<q>YOUR REVIEW HERE</q>
</p>
<p class = "reviewer">
<img src="http://www.cs.washington.edu/education/courses/cse190m/12sp/homework/2/critic.gif" alt="Critic" style="float:left;padding:5px;"/>
NAME <br />
<em>PUBLICATION</em>
</p>
</div>
And for reference, as well as to clarify my question, the output it supposed to look like this: http://courses.cs.washington.edu/courses/cse190m/12sp/homework/2/output/out-wide.png
So can anyone see why my floated columns aren't sitting beside the TMNT logo?

Alright, heres what I did: http://jsfiddle.net/PR3un/
<div class = "overview">
<img ... />
<dl>...</dl>
</div>
The only differences I did were...
Removed the clear:both,
Moved your dl into your ".overview" div
Removed the overview class from your dl
Floats are tricky. My favorite analogy that I tell my coworkers is this:
Using floats is like traveling through hyperspace. They exist, kinda, and can impact other DOM elements... but they are also travelling at a different dimensional plane (left-right). To bridge the float hyperspace travel, you can apply clear:both on itself or overflow:hidden on its parent.
... And if you apply float on a floating element's parent, it can provide a self-clear, but then the parent is traveling through hyperspace too.

Related

DomCrawler complex div nesting

I'm having trouble trying to get to some data using the dom crawler.
I want to get the name 'Avocado' and '£1.50' I though I'd be able to do something like
$message = $crawler->filterXPath('h3')->text();
<div class="product">
<div class="productInner">
<div class="productInfoWrapper">
<div class="productInfo">
<h3>
<a href="http://website.com" >
Avocado
<img src="pic.jpg" alt="" />
</a>
</h3>
</div>
</div>
<div class="pricingAndTrolleyOptions">
<div class="pricing">
<p class="pricePerUnit">
£1.50<abbr title="per">/</abbr><abbr title="unit"><span class="pricePerUnitUnit">unit</span></abbr>
</p>
<p class="pricePerMeasure">£1.50<abbr
title="per">/</abbr><abbr
title="each"><span class="pricePerMeasureMeasure">ea</span></abbr>
</p>
</div>
</div>
</div>
To get h3 text:
$message = $crawler->filterXPath('//div[#class="productInfo"]/h3')->text();
To get price (i.e. for class pricePerMeasure):
$price= $crawler->filterXPath('//p[#class="pricePerMeasure"]')->text();

Float text to the right of figure and figcaption

I discovered the "figure" and "figcaption" elements today. How do I wrap text next (right) to the image and caption.
<div>
<img alt="Hannibal Regional Medical Building" src="https://hannibalregionalmedicalgroup.org/Portals/0/locations/hannibal_regional_medical_building_375.jpg" width="375" height="178" style="text-align: left;" />
<figcaption>Hannibal Regional Medical Building</figcaption>
</div>
<div>
<p>
<span>Hannibal Regional Medical Group
<br />
6500 Hos​pital Drive<br />
Hannibal, MO 63401
</span>
</p>
</div>
<div>
<p><span>To make an appointment,<br />
please call 573-629-3500
</span>
</p>
</div>
Replace the first div with figure (only this is valid) and then put float:left; on the figure:
<figure style="float:left;">
<img alt="Hannibal Regional Medical Building" src="https://hannibalregionalmedicalgroup.org/Portals/0/locations/hannibal_regional_medical_building_375.jpg" width="375" height="178"/>
<figcaption>Hannibal Regional Medical Building</figcaption>
</figure>
<div>
<p>
<span>Hannibal Regional Medical Group<br/>
6500 Hos​pital Drive<br/>
Hannibal, MO 63401</span>
</p>
</div>
<div>
<p>
<span>To make an appointment,<br/>
please call 573-XXX-XXXX</span>
</p>
</div>
The HTML <figcaption> element represents a caption or a legend
associated with a figure or an illustration described by the rest of
the data of the <figure> element which is its immediate ancestor.
Permitted parents: A <figure> element; the <figcaption> element
must be its first or last child. -MDN
That means using a <div> tag as the immediate ancestor for a <figcaption> is invalid HTML in your example. To fix that you need to replace the <div> with <figure>.
<figure>
<img src="" alt="">
<figcaption>...</figcaption>
</figure>
And to make the rest of text to display on the right hand, there are many options, such as using float is the most common way.
figure {
float: left;
}
<figure style="float:left;">
<img alt="Hannibal Regional Medical Building" src="https://hannibalregionalmedicalgroup.org/Portals/0/locations/hannibal_regional_medical_building_375.jpg" width="375" height="178" />
<figcaption>Hannibal Regional Medical Building</figcaption>
</figure>
Demo:
http://jsfiddle.net/tuga/6va2nqad/3/

Header tag Background Color extending into Columns on iPad

I am working on a website and am having problems with the CSS on the IPAD (and possibly the iPhone).
Basically on the Sponsors page: http://www.tcsdesignreno.com/fsw/?page_id=1149. I am getting a red background behind the different sections. I think it has to do with the H3 tags that have a red background.
The same thing happens here: http://www.tcsdesignreno.com/fsw/?page_id=1165. They both are using the Easy Columns plugin in Wordpress.
Here is some sample HTML
<h3 class="sponsor-hdr" style="text-align: center;">Advertising and Media Partners</h3>
<div class="ezcol ezcol-one-third">
<p><a title="Fire Rescue 1" href="http://www.firerescue1.com/" target="_blank"><img class=" size-full wp-image-1238 aligncenter" src="http://www.tcsdesignreno.com/fsw/wp-content/uploads/2014/12/161_FR1_FC_Logo_Stacked.jpg" alt="FireRescue1.com, Fire Chief" width="161" height="93" /></a></p>
</div>
<div class="ezcol ezcol-two-third ezcol-last">
<p><strong>FireRescue1 / Fire Chief</strong><br />
200 Green St.<br />
2nd Floor<br />
San Francisco, CA 94111<br />
Phone: 415-962-5912</p>
</div><div class="ezcol-divider"></div>
<div class="ezcol ezcol-one-third">
<p><a title="CSFA" href="http://www.csfa.net/" target="_blank"><img class=" size-full wp-image-1233 aligncenter" src="http://www.tcsdesignreno.com/fsw/wp-content/uploads/2014/12/116_LatestCSFA-3_5_x_2_75_Logo.jpg" alt="California State Firefighters' Assn " width="116" height="91" /></a></p>
</div>
<div class="ezcol ezcol-two-third ezcol-last">
<p><strong>California State Firefighters’ Assn </strong><br />
2701 K Street, Suite 201<br />
Sacramento, CA 95816<br />
Phone: 800-451-2732<br />
Fax: 916-446-9889</p>
</div><div class="ezcol-divider"></div>
<h3 class="sponsor-hdr" style="text-align: center;">Program Sponsors</h3>
<div class="ezcol ezcol-one-third"><a title="FPAN" href="http://www.fpanevada.org/" target="_blank"><img class="aligncenter size-full wp-image-1232" src="http://www.tcsdesignreno.com/fsw/wp-content/uploads/2014/12/116_FPAN_Logo_Color.jpg" alt="FPAN" width="116" height="116" /></a></div>
<div class="ezcol ezcol-two-third ezcol-last">
<p>In appreciation to:<br />
<strong>Fire Prevention Association of Nevada</strong><br />
<strong>National Code Services Association</strong></p>
</div><div class="ezcol-divider"></div>
<h3 class="sponsor-hdr" style="text-align: center;">Tote Bag Sponsors</h3>
<div class="ezcol ezcol-one-third"><a title="Burton's Fire" href="http://www.burtonsfire.com/" target="_blank"><img class="aligncenter size-full wp-image-1236" src="http://www.tcsdesignreno.com/fsw/wp-content/uploads/2014/12/158_BURTONS_FIRE_INC_LOGO.jpg" alt="BURTONS FIRE" width="158" height="54" /></a></p>
</div>
<div class="ezcol ezcol-two-third ezcol-last">
<p><strong>Burton’s Fire</strong><br />
1301 Doker Avenue<br />
Modesto, CA 95351<br />
209-544-3161</p>
</div><div class="ezcol-divider"></div>
<div class="ezcol ezcol-one-third"><a title="Waterous" href="http://www.waterousco.com/" target="_blank"><img class="aligncenter size-full wp-image-1237" src="http://www.tcsdesignreno.com/fsw/wp-content/uploads/2014/12/158_WaterousLogoSm.jpg" alt="Waterous" width="155" height="29" /></a></p>
</div>
CSS:
h3 {
background-color: #990000;
color: #ffffff;
padding: 10px 0;
text-align: center;
width: 100%;
max-height:92px;
}
Here is an image:
Can anyone see why these sections are showing up in red? For the life of me I can't seem to figure it out.
Looks like your floats aren't clearing. You can add this to your current styles:
.singlepost .content-entry h3 {
clear: both;
}

Odd DIV behavior with media query

On the following page (http://www.ecu.edu/cs-cas/engl/tpc/whytpc.cfm) you can see that, on a mobile device, the columns collapse into a single column. However, the content which appears in the right column is shifted to the right somewhat. The CSS in the media query is:
#media only screen and (max-device-width: 480px) {
#content {
float:left;
max-width:50%;
padding:1em 0 1em 0%;
}
#sidebar {
float:left;
max-width:50%;
padding-top:1em;
}
.spacerMain {
display: block;
padding: none;
color: #2a272e;
width: 100%;
}
.column {
display: block;
width: 100%;
float: left;
clear: both;
}
.spacerCol {
display: block;
width: 100%;
padding: none;
color: #2a272e;
clear: both;
float:left;
}
}
and the HTML:
<div id="container">
<div id="header">
<div id="navigation">
<ul>
<li>Home</li>
<li>Why TPC?</li>
<li>Programs</li>
<li>TPC Social</li>
<li>Questions?</li>
</ul>
</div>
<div id="navigation2">
<ul>
<li><img width="45px" height="45px" alt="Facebook" src="/cs-cas/engl/tpc/customcf/facebook.png" /></li>
<li><img width="45px" height="45px" alt="Twitter" src="/cs-cas/engl/tpc/customcf/twitter.png" /></li>
<li><img height="45px" alt="Linked In" src="/cs-cas/engl/tpc/customcf/linkedin.png" /></li>
<li><img width="45px" height="45px" alt="Purple Bard" src="/cs-cas/engl/tpc/customcf/bardicon.png" /></li>
</ul>
</div>
</div>
<div id="content">
<div id="main">
<div id="spacerMain">
<div class="column">
<div class="spacerColFirst">
<h3 class="sectionTitle">Why TPC at ECU?</h3>
The ECU Department of English offers two innovative online graduate programs in technical and professional communication: the <span style="color: rgb(4, 46, 238); ">Certificate in Professional Communication</span> and the MA concentration in TPC.</div>
<div class="spacerColFirst"><br />
</div>
<div class="spacerColFirst">Every profession needs excellent communicators, and communication itself is becoming an increasingly complex skill set that combines strong writing and editing skills, teamwork, technological sophistication, leadership, adaptability, global awareness, and disciplinary knowledge.<br />
<br />
As part of our master's degree program, you will gain broad proficiency in all these essential areas. In consultation with your faculty advisor and other mentors, you can also focus on one or more areas of emphasis, including </div>
<div class="spacerColFirst">
<ul>
<li><span style="line-height: 1.3em;"><font size="2">technical editing and publishing</font></span></li>
<li><span style="line-height: 1.3em;"><font size="2">emerging media and communication technologies</font></span></li>
<li><span style="line-height: 1.3em;"><font size="2">teaching and training; and </font></span></li>
<li><span style="line-height: 1.3em;"><font size="2">public and civic communication in contexts such as healthcare, science, government, or service organizations.</font></span></li>
</ul>
As a certificate student, you can broaden your communication proficiency by sampling across the range of our courses or develop advanced skills in a specific area of interest.<br />
<br />
As members of a large and dynamic English department, MA students are also encouraged to take advantage of the full range of courses offered in other areas of English, including rhetoric and composition, linguistics and TESL, film, folklore, literature, creative writing, and multicultural and transnational studies.</div>
</div>
</div>
<div class="column">
<div class="spacerCol">
<h3 class="sectionTitle">TPC and your Career Goals</h3>
Our programs offer practicing communication professionals the opportunity to step back from their everyday tasks to reconsider the technological changes and communication principles that shape their work environments.<br />
<br />
Our courses combine cutting-edge theories and contemporary professional practices. Many courses use a project approach, helping students to develop sophisticated workplace communication products while they learn fundamental principles of professional communication in contemporary workplaces.<br />
<br />
Our graduates become public information officers, fund raising and educational outreach professionals, program directors and communication specialists, trainers, content developers, technical editors, and technical communicators in high-tech industries. Others become educators at community colleges or four-year colleges and universities.<br />
<br />
If your career goals include effective communication, our programs can help.</div>
</div>
</div>
</div>
<div id="sidebar">
<dl>
<dt>Program Links</dt>
<dd>MA Degree (TPC Concentration)</dd>
<dd><br />
</dd>
<dd>Graduate Certificate in TPC</dd>
<dd><br />
</dd>
<dd>Course Advising and Registration</dd>
<dd><br />
</dd>
<dd>English Graduate Program</dd>
<dd><br />
</dd>
<dd>English Graduate Catalog</dd>
<dd><br />
</dd>
<dd>English Graduate Curricula<br />
<br />
</dd>
</dl>
<dl>
<dt>Links for Students</dt>
<dd>ECU Department of English<br />
<br />
The Graduate School at ECU<br />
<br />
ECU Academic Calendars<br />
<br />
Blackboard Student Access<br />
<br />
Student E-Mail Access<br />
<br />
Pirate Port<br />
</dd>
</dl>
<dl>
<dt>#ECUTPC</dt>
<dd>
<ul id="twitter_update_list">
<li style="list-style: none">%nbsp</li>
<li class="twitter_date">%nbsp</li>
</ul>
</dd>
</dl>
</div>
<div id="footer"> </div>
</div>
It's not shifted, the sidebar is ocupying just 50% of the width.
But, inside the sidebar, the "dl" elements have a margin left of 1em; that is the space that you see that makes it look like "shifted".
Anyway, if you are going to take of this margin, you should give some margin right to the left column, other wise they will be "touching"
I used a margin-left: -2m; in the CSS to fix the text-column problem. That seems to have cleared it up on mobile browsers.

Placing divs next to each other rather than below

I'm having trouble with placing divs next to each other rather than having them below. I'm new to using CSS and I'm not sure what I need to do exactly.
The webpage is www.panduzee.com/wordpress
The post "Richard Lu" is suppose to be next to "Ashley Lee."
The link to the code is: http://pastebin.com/J3CNMfaP
And the CSS is: http://pastebin.com/isn5NViA
Sorry, I tried getting the code to work within this post but it wasn't showing up correctly.
Any help would be appreciated! The CSS was from the wordpress theme, just letting you all know.
Thank you!
jsFiddle( http://jsfiddle.net/BnJ7g/3/ )
on your "boxes" and "boxes2" divs, add the float:left attribute.
<div id="boxes" style="float:left;">
<div class="box">
<!--The post title-->
Ashley Lee <!--The post image-->
<img width="210" height="312" src="http://www.panduzee.com/wordpress/wp-content/uploads/2012/04/527802_2560693355446_1797426028_1635316_739143794_n-210x312.jpg" class="attachment-homepage-thumb wp-post-image" alt="" title="" />
</div>
</div>
<div id="boxes2" style="float:left;">
<div class="box">
Richard Lu <!--The post image-->
<img width="210" height="312" src="http://www.panduzee.com/wordpress/wp-content/uploads/2012/04/527802_2560693355446_1797426028_1635316_739143794_n-210x312.jpg" class="attachment-homepage-thumb wp-post-image" alt="" title="" />
</div>
</div>
​

Resources