I know there are several posts about this but none of the solutions are working for me. With that said, my containing div will not grow with my content. I know why this is happening, because it is 'float'ing but even when I use 'clear' it will not expand with the parent div. I've tried using using clear in nearly every element below with no success. Any help would be greatly appreciated.
View Image of problem:
For a live example please visit, http://thehopcompany.com/index.php?id=49
---------------CSS----------------
.product {
width:775px;
margin:0;
padding:0;
margin-top:75px;
margin-left:-8px;
}
.product ol{
margin:0px;
}
.product li{
list-style:none;
margin: 0 0 15px 0;
padding:15px;
border:1px solid #ccc;
height:100px;
color:#000;
}
.product-column-left{
float:left;
width:100px;
height:100px;
}
.product-column-right{
float:left;
width:120px;
border-left:1px solid #ccc;
height:100px;
text-align:center;
}
.product-column-center{
float:left;
width:470px;
min-height:100px;
padding-right:15px;
padding-left:15px;
text-align:left;
padding-bottom:30px;
display:block;
}
.product h2{
font-size:18px;
margin-bottom:5px;
margin-top:0;
}
.product .text-underline{
text-decoration:underline;
}
.description-text{
font-size:12px;
color: #000;
}
.clear{
clear:both;
}
--------------------------HTML--------------------------
<li style="list-style:none;">
<div style="width:750px;" >
<div class="product-column-left">
<img align="left" style="border:0;" src="images/hop-pellets.png" width="100" height="100" />
</div>
<div class="product-column-center" >
<h2><span class="hop-title-text-product">Columbus, Tomahawk and Zeus</span></h2>
<div class="description-text" >Proprietary naming rights sometimes have identical or nearly identical strains being sold under multiple names. Columbus, Tomahawk and Zeus, or the CTZ hops, are the most famous example of this phenomenon. CTZ hops are known as super-alpha hops due to the extremely high percentage of alpha acids they contain, making them ideal bittering additions. Columbus hops can be found alongside Centennial hops in Stone Ruination IPA or in Saranac's Brown Ale.
Proprietary naming rights sometimes have identical or nearly identical strains being sold under multiple names. Columbus, Tomahawk and Zeus, or the CTZ hops, are the most famous example of this phenomenon. CTZ hops are known as super-alpha hops due to the extremely high percentage of alpha acids they contain, making them ideal bittering additions. Columbus hops can be found alongside Centennial hops in Stone Ruination IPA or in Saranac's Brown Ale.
</div>
<div class="product-column-right">
<h2>$0.00</h2>
<img style="margin-top:10px; border:0;" type="image"src="images/add-to-cart-button.png" width="90" height="25" />
</div>
</div>
</li>
</ol>
</div>
Try to add overflow hidden to the parent li
.product li {
....
overflow: hidden;
/*height: 100px;*/
}
The problem with overflow:hidden is it will hide overflowing elements if you have them in your layout. So by using clearfix which is i suppose the best practice you can acheive it like below.
.clearfix:after {
content: " "; /* Older browser do not support empty content */
visibility: hidden;
display: block;
height: 0;
clear: both;
}
Then, basically you just need to add the class in your container elements. More about Clearfix
<li class="clearfix">
<div style="float: left;">
<div class="content">Big content</div>
</div>
</li>
FIDDLE DEMO
Adding a clearfix should solve your problem:
.clear{width: 100%; clear: both; height: 0px; line-height:0px;}
<div class='clear'></div>
.clear{width: 100%; clear: both; height: 0px; line-height:0px;}
<div class='clear'></div>
Add the above div at the very end of your container div (i think after product-column-right) and just before your closing li tag. That should ensure that the div spans the content.
Your product.li style has a height of 100px, so that's going to constrain the box no matter what. Remove that setting (or change it to height:auto) and then add an empty clear div just before the closing li tag and you should be fine.
So your CSS definition would change to:
.product li{
list-style:none;
margin: 0 0 15px 0;
padding:15px;
border:1px solid #ccc;
height:auto;
color:#000;
}
And then the relevant HTML:
<img style="margin-top:10px; border:0;" type="image"src="images/add-to-cart-button.png" width="90" height="25" />
</div>
</div>
<div style="clear:both"></div>
</li>
</ol>
</div>
I was using overflow: for a while with much success - but I had a few problems and decided to go back to this clear fix. If you have any problems - check it out.
http://css-tricks.com/snippets/css/clear-fix/
Related
I want to set up a full width slideshow based on the Design I've prepared. I'm building the page on the Unsemantic CSS framework as I was already familiar with 960 gridsystem (960.gs).
What I'm missing is how to write physically correct HTML & CSS. I don't want to build these unstable workarounded glued pages like most.
I've tried my best to build it but nothing seems to work the way it should. Here is a part of the page where a slideshow should appear.
However, it looks like this.
Here's the CCS:
<style>
.slide-wrapper{
background-color:black;
width:100%;
overflow:hidden;
}
.slide-item{
width:100%;
overflow:hidden;
color:white;
}
.slide-img-wrapper{
position:relative;
}
.slide-img{
width:100%;
float:left;
position:relative;
}
.slide-description{
position:absolute;
float:left;
text-align:center;
width: 100%;
margin-top:16%;
}
.description-wrapper{
}
</style>
<div id="slide-wrapper">
<div class="slide-item">
<img class="slide-img" src="../villas.praivit/img/lead.jpg" />
<div class="slide-description">
<p class="location">SWITZERLAND, CERN</p>
<h1>VILLA PANORAMA</h1>
<p class="details">Local Time <b>4:10 am</b>, Temperature <b>32F°</b></p>
<div class="button-1">VIEW VILLA</div>
</div>
</div>
</div>
Is this what you are looking for?
<div id="slide-wrapper">
<div class="slide-item">
<img class="slide-img" src="http://dreamatico.com/data_images/mountain/mountain-1.jpg" />
<div class="slide-description">
<p class="location">SWITZERLAND, CERN</p>
<h1>VILLA PANORAMA</h1>
<p class="details">Local Time <b>4:10 am</b>, Temperature <b>32F°</b></p>
<div class="button-1">VIEW VILLA</div>
</div>
</div>
</div>
.slide-wrapper{
background-color:black;
width:100%;
overflow:hidden;
}
.slide-item{
width:100%;
overflow:hidden;
color:white;
}
.slide-img-wrapper{
position:relative;
}
.slide-img{
width:100%;
float:left;
position:relative;
}
.slide-description{
position:absolute;
float:left;
text-align:center;
width: 100%;
margin-top:16%;
}
.description-wrapper{
}
.button-1{
display: inline-block;
background-color: #b8955d;
color: #fff;
box-sizing: border-box;
padding: 10px;
}
.button-1 a{
color: #fff;
text-decoration: none;
}
http://www.walkerspencer.com/chrhsweb/max
So I'm currently working on a high school project, and I'm completely stumped. One of my divs, article, isn't behaving how I'd like it to. It has a height of 0. Now, after a lot of googling and research, it seemed like this was a common issue... for containers which contained floating elements. My article contains no floating divs. I even tried removing float from the css for my #buttons div, and it had no effect. I've also tried most of the suggested float fixes: the clearfix method, clear:both. At this point, I just need an outside opinion. I couldn't find any major errors in my code (besides a general disorganization and misuse of semantic elements). The intended behavior is that sections scale while maintaining a 16:9 ratio as the browser resizes, and have a black transparent background that fills the entire article. I could also apply the background to article, but article doesn't have a height either. If you'd just like to critique my bad code habits and formatting, that's alright too :). The images' absences shouldn't be important, though they are in a 16:9 ratio, and I had this problem before adding any jquery. Thank you so much. Sorry if there's an issue with my post or how I've asked it, it's my first time asking a question on here.
HTML:
<head>
<meta charset='utf-8'/>
<title>design</title>
<link rel="stylesheet" type="text/css" href="reset.css"/>
<link rel="stylesheet" type="text/css" href="style.css"/>
<link href='http://fonts.googleapis.com/css?family=Lato:100' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.cycle.all.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#images").cycle({
containerResize: false,
slideResize: false,
fit: 1
});
$('article').cycle({
activePagerClass: 'activeSlide',
containerResize: false,
slideResize: false,
fit: 1,
timeout: 0,
speed: 300,
startingSlide:0,
pager: "#buttons",
pagerAnchorBuilder: function(idx, slide) {
return '#buttons li:eq(' + idx + ')';}
});
$('#right').click(function() {
$('article').cycle("next");
return false;
});
$('#left').click(function() {
$('article').cycle("prev");
return false;
});
});
</script>
</head>
<body>
<div id="container">
<div id="arrows">
<div id="left"><</div><div id="right">></div>
</div>
<nav>
<ul id="buttons">
<li>
<li>
<li>
<li>
<li>
</ul>
</nav>
<div class="fix"></div>
<article>
<section id="images">
<img src="images/alaska.jpg" width="100%" height="auto"/>
<img src="images/field.jpg" width="100%" height="auto"/>
<img src="images/sunset.jpg" width="100%" height="auto"/>
</section >
<section id="about">
<p>
my name is <span style="color:crimson">max</span>.<br>
i'm a senior in high school.<br>
i love <span style="color:yellow">code</span><br>
<span style="color:#a45bc4">&</span><br>
i love <span style="color:lightgreen">design</span>.<br>
<span style="color:#a45bc4">welcome to my site.</span>
</p>
</section >
<section id="work">
</section >
<section id="contact">
</section>
<section id="place">
</section>
</article>
<div id="bottom"></div>
</div>
</body>
CSS:
body{
background-image:url("images/clouds.jpg");
background-size:cover;
background-color:white;
background-repeat:no-repeat;
height:100%
}
#container{
width:70%;
min-height:103px;
margin:0 auto;
min-width:182px;
}
#arrows{
max-width: 140px;
height: 70px;
background: #f7f7f7;
-moz-border-radius: 70px 70px 0 0;
-webkit-border-radius: 70px 70px 0 0;
border-radius: 70px 70px 0 0;
margin:auto;
position:relative;
top:25px;
z-index:100;
border-top:1px solid;
border-color:#cccccc;
font-family:"Lato";
text-align:center;
vertical-align:middle;
line-height:60px;
font-size:68px;
color:#cfcfcf;
font-weight:100;
font-stretch:ultra-condensed;
}
#right:hover, #left:hover{
color:#a45bc4;
text-decoration:none;
}
#right, #left{
display:inline;
color:#cfcfcf;
text-decoration:none;
cursor:pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
}
nav{
width:calc(100%-2px);
border-left:1px solid #cfcfcf;
border-right:1px solid #cfcfcf;
height:35px;
background-color:#f7f7f7;
min-width:182px;
}
#buttons{
position:relative;
float:right;
margin-right:6px;
z-index:100;
}
.fix{
clear:both;
}
.current{
padding-right:0px;
}
#buttons li{
display:inline-block;
height:26px;
width:26px;
background-image:url("images/navc.jpg");
background-repeat:no-repeat;
background-position:center;
background-size:24px;
margin-left:8px;
margin-top:4px;
vertical-align:middle;
cursor:pointer;
}
#buttons li:hover{
opacity:.8;
}
#buttons a{
color:black;
text-decoration:none;
}
#buttons li.activeSlide{
background-image:url("images/violetc.jpg");
height:26px;
width:26px;
background-size:26px;
vertical-align:middle;
}
article{
width:100%;
min-width:184px;
height:100%;
}
section{
height:100%;
width:100%;
margin:0 auto;
text-align:center;
vertical-align:middle;
color:white;
font-weight:100;
font-size:36px;
font-family:"Lato";
background-color:rgba(0,0,0,.4);
}
p{
}
#about{
}
.option img{
opacity:.6
}
.option:hover{
opacity:.8;
}
#bottom{
border-left:1px solid #cfcfcf;
border-right:1px solid #cfcfcf;
border-bottom:1px solid #cfcfcf;
height:30px;
background-color:#f7f7f7;
min-width:182px;
margin-top:56.25%;
}
#media all and (max-width:690px){
#buttons{
margin-top:2px;
width:98%;
text-align:center;
}
nav{position:relative;
text-align:center;}
}
If you're keeping the slideshow plugin, and it is what's causing the absolutely positioned children (you're not doing it,) then your only option is to force the height of the article element, if you want to use it for something.
You can either apply a class/ID to it (if you're using other article elements that have nothing to do with this style, and you only use it once per page, then use an ID, or if you want to re-use it somewhere else on the same page, use a class.) So you would have something like:
article.slideshow-container { height: 498px; }
And you can then use it for whatever you want. This is a fixed-height though, so if image height changes, you lose out again.
The problem is definitely with your implementation of the jQuery Cycle Plugin. As setek has mentioned, the slideshow makes your section divs position absolute, which collapses the height of the article element to 0. You can add the following to your cycle script to dynamically adjust the height for each slide/section:
before : function(currSlideElement, nextSlideElement){
$('article').css('height', $(nextSlideElement).height()+'px');
},
You should also clean up your code (it is a bit of a mess) and try to take things step by step. I have created a working example for you here:
http://jsfiddle.net/BCyD8/
You will have to work a bit to get the spacing right.
img moved to bottom after float:right;
see to footer: http://qass.im/thestandard/
this footer code:
footer{
display:block;
margin:0 auto;
margin-bottom:50px;
width:800px;
height:100%;
clear:both;
}
.footer-content{
padding:80px;
padding-top:0;
padding-bottom:0;
}
footer p{
line-height: 1.714285714;
font-size:14px;
color:#555;
}
footer p a{
color:#555;
border-bottom:1px dotted #555;
}
.social-icon{
font-size:0;
float:right;
}
Do it this way.
The Code Changes:
<div class="footer-content">
<div class="social-icon">
<a target="_blank" href="#"><img src="http://qass.im/thestandard/wp-content/themes/thestandard/images/twitter-footer.png"></a>
<a target="_blank" href="#"><img src="http://qass.im/thestandard/wp-content/themes/thestandard/images/facebook-footer.png"></a>
<a target="_blank" href="#"><img src="http://qass.im/thestandard/wp-content/themes/thestandard/images/google-footer.png"></a>
</div>
<p>
Powered by <a target="_blank" href="http://wordpress.org">WordPress</a> ©2013 The Standard, The Standard theme by <a target="_blank" href="http://qass.im/thestandard">Qassim.Dev</a>
</p>
</div>
This will make your image not to jump to the bottom.
They are rendered under the paragraph. As a p tag is block-level - so it occupies the full width.
What you can do:
variant 1: make .footer-content p {float: left;}
variant 2: change the order in your html. Make the div with a class of social-icon go before the paragraph.
delete the .social-icon's float
and use display:inline; for .social-icon and footer p
i have visited your page it isnt on the bottom because of float:right; (use a debugger - like firebug - and disable float:right; to check), its there because of the fact that it is a block element under another block element use display:inline-block; in your .social-icon and footer p css.
in conclusion
footer p{
display:inline-block;
}
.social-icon{
display:inline-block;
font-size:0;
float:right;
}
and BOOM! i did this in firebug on your site and it worked fine.
I have a top nav that extends across the page
Within that top nav I have various elements
two that must align left
one that must align right
The nav is fluid the elements are fixed widths
Do not want the elements to wrap when the browser window is minimized
Needs to work in IE6 on up due to high Chinese audience.
See example here:
http://jsfiddle.net/4SUwg/
<div id="header">
<div id="headerContent">
<div class="search-list"> Search List </div>
<div class="social-buttons"> Social </div>
<div class="signin"> Login Drop Down </div>
</div>
</div>
I would like the div elements within the nav to not wrap. I searched around on stack and could find answers that come close but nothing that completely addressed the issue. My need to have the div element aligned right complicates matters. Must work in all browsers, especially IE's.
Thanks all for your help in advance!!!
Use SPAN .. It's INLINE and not BLOCK ??
<div id="header">
<div id="headerContent">
<span class="search-list"> Search List </span>
<span class="social-buttons"> Social </span>
<span class="signin"> Login Drop Down </span>
</div>
</div>
And your CSS, remove floats
<style>
body {
margin:0;
padding:0;
}
#header {
background: #404040;
height: 35px;
color: white;
margin: 0 0 12px 0;
overflow-x:auto; overflow-y:hidden;
}
#headerContent {
height: 32px;
border:1px dashed #fff;
}
.search-list {
width:150px;
background:#039;
}
.social-buttons {
width:150px;
background:#060;
}
.signin {
width:200px;
background:#F00;
}
You want a fluid layout but the most important rule of a fluid layout is not to set a definite width of elements but you have set the width.
The CSS have a <style> tag, which is not required, probably you put it by mistake.
I have set the width of divs inside headerContent in percentage value. The CSS is
body {
margin:0;
padding:0;
}
#header {
background: #404040;
height: 35px;
color: white;
margin: 0 0 12px 0;
overflow-x:auto; overflow-y:hidden;
}
#headerContent {
height: 32px;
border:1px dashed #fff;
}
.search-list {
width:28%;
float:left;
background:#039;
}
.social-buttons {
width:28%;
float:left;
background:#060;
}
.signin {
width:28%;
float:right;
background:#F00;
}
Just changed the width value and on my browser it looked fine, better than the before version. Here's a fiddle http://jsfiddle.net/DeepakKamat/s52Hn/8/
I found a solution that works in all browsers, specifically IE6 on up since that was a requirement for this project. If you have something better that accomplishes the same thing please post! My sincere thanks to everyone who answered/helped.
<div id="header2">
<table id="headerContent2">
<tr>
<td id="left" valign="top">
<div id="leftWrapper">
<div class="search-list2">Search List</div>
<div class="social-buttons2">Social Buttons</div>
</div>
</td>
<td id="middle"> </td>
<td id="right" valign="top">
<div class="signin2">Login Drop Down</div>
</td>
</tr>
</table>
</div>
<style>
#header2 {
background: #404040;
height: 35px;
color: white;
margin: 0 0 12px 0;
}
#headerContent2 {
width:100%;
}
#headerContent2 td {
height: 32px;
padding:0;
margin:0;
}
.search-list2 {
width:150px;
float:left;
background:#039;
}
.social-buttons2 {
width:200px;
float:left;
background:#060;
}
.signin2 {
background:#F00;
float:right;
width:400px;
}
#leftWrapper {
width:400px;
}
#middle {
width:100%;
}
</style>
See Demo of it working here. Copy the code and try it out in all the IE's since JSfiddle does not work in all IE's.
http://jsfiddle.net/GtXKE/
Trying to get these list headings to line up correctly, but I can't figure out the justification to get it to line up. Trying to style it like the second one but those bold tags are pushing it down a line.
<div class="block">
<ul class="toc partThree">
<li><b>39:</b>Maintaining This Diet</li>
<br/>
<li><b class="parts">Part 3A:</b><a class="partslink" href="#"> About Fruit Consumption</a></li>
<li><b>40:</b>Ideal Fruit-combinations</li>
<li><b>41:</b>Fruits To Go</li>
<li><b>42:</b>Salads & Shakes</li>
<li><b>43:</b>Fruits In General</li>
<li><b>44:</b>About Consuming Nuts</li>
<br/>
<li><b class="parts">Part 3B:</b><a class="partslink" href="#"> About Consuming Animal Food</a></li>
<li><b>45:</b>About Fresh Raw Fish</li>
<li><b>46:</b>About Fresh Raw Egg Yolk</li>
<br/>
<li><b class="parts">Part 3C:</b><a class="partslink" href="#"> The Most Important Section of This book</a></li>
<li><b>47:</b>Remember That...</li>
<li><b>48:</b>The Rules</li>
<li><b>49:</b>The Obstacles</li>
<li><b>50:</b>Cravings</li>
<li><b>51:</b>Traps</li>
<li><b>52:</b>How To Pick Munch-foods</li>
<li><b>53:</b>Protein Contents</li>
<li><b>54:</b>Single Munch-food Items</li>
<li><b>55:</b>Munch-food Meals</li>
</ul>
</div>
Here is the CSS:
.toc{
list-style:none;
font-size: 15px;
}
.toc li{
margin:0 0 0 10px;
width: 220px;
overflow:hidden;
font-size:13px;
font-family:Arial;
}
.toc b{
float:left;
padding: 0 4px 0 0;
font-weight:bold;
}
.toc a{
float:left;
width:191px;
padding:0 0 0 0px;
color: black;
text-decoration:none;
}
.toc a:hover{
color: rgba(0,0,0,.8);
text-decoration: underline;
}
b.parts{
}
a.partslink{
}
http://jsfiddle.net/QbUvD/
Made some adjustments, particularly removing floats. This is assuming you don't use the suggestion above of the counter-reset (although with that you'd have to restructure a lot of your HTML it seems).
the trick I used here is to add a padding-left to the li's that are title (add a class .title) then using a negative text-indent to wrap back the first line, but allow the second one to keep the padding. The only downside here is the need for a manual width on the padding/indent values, but it achieves the look you want.