Three column layout, all three columns taking up 1/3 of the page. Height of 100%.
http://jsfiddle.net/9ngN3/4/
The column with the most <div class="aTweet">'s in it decides the height of all three columns. The others are 'pulled' down to its height.
I want all three columns to be the same height, with the tweets being at the top. The empty space at the bottom of a column being filled with grey (background).
I just don't see why they are being pulled down to the bottom. It gets super interesting when you set height in .thirdCol to 400px (for eg).
Any ideas? I'm sure this is simple but i'm just missing it. Thanks.
(Using Chrome + Opera BTW)
Code in the JS Fiddle -
HTML:
<div id="manageStockGridArea" class="mainContentGridArea">
<div id="FeedsTab" class="BlockInputArea">
<div id="feed1" class="thirdCol">
<div class="fitler">
<select><option>OP1</option><option>Op2</option></select>
<select><option>OP1</option><option>Op2</option></select>
</div>
<div class="streamContainer">
<div class="aTweet">
<span class="tweetHandle">AtPeelypeel (firstName lastName)</span>
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nec purus in ante pretium blandit. Aliquam erat volutpat. Nulla libero lectus.</span>
</div>
</div>
</div>
<div id="feed2" class="thirdCol">
<div class="fitler">
<select><option>OP1</option><option>Op2</option></select>
<select><option>OP1</option><option>Op2</option></select>
</div>
<div class="streamContainer">
<div class="aTweet">
<span class="tweetHandle">AtPeelypeel (firstName lastName)</span>
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nec purus in ante pretium blandit. Aliquam erat volutpat. Nulla libero lectus.</span>
</div>
<div class="aTweet">
<span class="tweetHandle">AtPeelypeel (firstName lastName)</span>
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nec purus in ante pretium blandit. Aliquam erat volutpat. Nulla libero lectus.</span>
</div>
</div>
</div>
<div id="feed3" class="thirdCol">
<div class="fitler">
<select><option>OP1</option><option>Op2</option></select>
<select><option>OP1</option><option>Op2</option></select>
</div>
<div class="streamContainer">
<div class="aTweet">
<span class="tweetHandle">AtPeelypeel (firstName lastName)</span>
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nec purus in ante pretium blandit. Aliquam erat volutpat. Nulla libero lectus.</span>
</div>
</div>
</div>
</div>
CSS:
body,html, #manageStockGridArea{height:100%; min-height: 100% !important;}
.thirdCol
{
width:32.5%;
display:inline-block;
background-color:grey;
height:400px;
}
.aTweet
{
background-color:Teal;
}
.tweetHandle
{
display:block;
}
Being inline-block you can control the alignment with vertical-align:
http://jsfiddle.net/9ngN3/4/
#FeedsTab > div{
vertical-align: top;
}
In terms of the columns the same height, there are many tricks available for faux-columns in CSS. Take a look at this example on CSS tricks for more information.
Modify your CSS as follows:
.thirdCol {
width:32.5%;
display:inline-block;
background-color:grey;
min-height:100%;
vertical-align: top;
}
By default, the inline blocks are vertically aligned to the baseline of the text, which corresponds to the baseline level of the bottom-most line of each text block.
Note: Getting the background color is a bit trickier...
You can try this:
demo
.thirdCol
{
width:32.5%;
display:inline-block;
background-color:grey;
min-height:100%;
vertical-align:top;
}
Related
I am trying to align both paragraphs under the left side of an image, but I can't seem to figure it out. I am also trying to make the width of the text the same width of the image. I need to keep the div align="center" in there so the bootstrap row is on the center of the page. Please help!
Here is an image from my web design on how i'm trying to align it. http://i.imgur.com/kIbyBUS.png
Here is the html code.
https://jsfiddle.net/kvu7y8ym/
<div align="center">
<div id="preview" class="col-lg-4 col-md-6 col-sm-12">
<img id="img" src="http://i.imgur.com/HHGHTsu.png">
<p><b>EXAMPLE WEB DESIGN</b></p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Vestibulum lobortis diam ut ipsum egestas scelerisque. Nam semper lorem
at cursus pulvinar. Ut luct diam.</p>
</div>
</div>
The simplest to accomplish that is to use 2 wrappers, an inline-block and a table-caption.
The table-caption will keep the text within the image's edges, and the inline-block will be centered with the text-align: center set on the #preview element.
#preview {
text-align: center;
}
.inline-block {
display: inline-block;
}
.tbl-caption {
display: table-caption;
text-align: left;
}
<div>
<div id="preview" class="col-lg-4 col-md-6 col-sm-12">
<div class="inline-block">
<div class="tbl-caption">
<img id="img" src="http://i.imgur.com/HHGHTsu.png">
<p><b>EXAMPLE WEB DESIGN</b></p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum lobortis diam ut ipsum egestas scelerisque. Nam semper lorem at cursus pulvinar. Ut luct diam.</p>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div id="preview" class="col-lg-offset-4 col-md-offset-3 col-lg-4 col-md-6 col-sm-12">
<img id="img" src="http://i.imgur.com/HHGHTsu.png">
<p><b>EXAMPLE WEB DESIGN</b></p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Vestibulum lobortis diam ut ipsum egestas scelerisque. Nam semper lorem
at cursus pulvinar. Ut luct diam.</p>
</div>
</div>
</div>
I'd do it this way if you're using Bootstrap (which it seems like you are because you're using col-lg-4 etc.
When you use those classes they expect to be inside container and then inside a row use different offsets to center the content after that, see example above.
I have whitespace above a row/container (Im not sure which, probably the container?) that I need gone. The code is straightforward,
<div class="row">
<div class="col-md-9">
<blockquote data-wow-delay="0.1s" data-wow-duration="1s" class="about-quote wow fadeInUp">
<div>
<h1 id="one">big</h1>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac felis sed eros bibendum tincidunt.
</div>
<div>
<h1 id="two">willy</h1>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac felis sed eros bibendum tincidunt.
</div>
</blockquote>
</div>
Nothing fancy, yet there is constant chunk of whitespace above it separating it from the element above.
I've tried removing it with
body {
margin: 0 !important;
padding: 0 !important;
}
and by replacing body with container, row and col respectively, but the white space remained and it just messed up the layout.
I'm making a new website and in my sidebar I'm trying to add this section below but I'm struggling to get the about text to be to the right of the image. I've tried floating the text left but it didn't really work. The only CSS I've got so far is that the sidebar is 300px wide.
<div id="sidebarabout">
<h3>About Elliott Davidson</h3>
<img src="http://placehold.it/100x100"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam rhoncus luctus odio, sed sagittis dolor volutpat ut. Pellentesque efficitur orci at nunc fermentum, nec feugiat erat gravida. Continue reading</p>
</div>
Add this css and check out
img{float:left;padding:0 15px 0 0}
https://jsfiddle.net/vasanthanvas/s4pb17tr/
Try like this
<p><img src="http://placehold.it/100x100"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam rhoncus luctus odio, sed sagittis dolor volutpat ut. Pellentesque efficitur orci at nunc fermentum, nec feugiat erat gravida. Continue reading</p>
img{float:left;margin:0 15px 0 0}
Padding will squeeze your image little.
You can use margin instead of padding.
You need to set the img and p to be either inline or inline-block on their CSS styles.
And also - depending how you want your text to "float" it may need a width:
https://jsfiddle.net/xoL510og/ << Example
<div id="sidebarabout">
<h3>About Elliott Davidson</h3>
<img style='display:inline-block;' src="http://placehold.it/100x100"><p style='display:inline-block; width:400px;'>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam rhoncus luctus odio, sed sagittis dolor volutpat ut. Pellentesque efficitur orci at nunc fermentum, nec feugiat erat gravida. Continue reading</p>
</div>
use display: table;
*{
padding: 0;
margin: 0;
box-sizing: border-box;
}
.item-inner{
display: table;
width: 100%;
padding: 20px;
}
.item{
display: table-cell;
vertical-align: top;
}
.item-text{
padding-left: 15px;
}
<div class="item-inner">
<div class="item">
<img src="http://placehold.it/100x100" />
</div>
<div class="item item-text">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam rhoncus luctus odio, sed sagittis dolor volutpat ut. Pellentesque efficitur orci at nunc fermentum, nec feugiat erat gravida. Continue reading</p>
</div>
When defining the img markup, make sure that it only affects the sidebarabout div. So define the div before img. Example:
#sidebarabout img{
float: left;
padding: 0 15px 0 0;
}
In case u declared a width in ur paragraph element, for example 200px, make sure to reduce this to 185px, since we're using a 15px padding. Otherwise it will mess up ur webpage because the div will become 315px width.
I noticed someone suggested using a margin. Don't use a margin, this will only push the image 15px to the left out of the div.
Also i'm missing a width, height and alt. Make sure to define ur img element the right way, otherwise it will not pass the W3C validator. Use the following:
<img src="http://placehold.it/100x100" width="100" height="100" alt="Description">
I'm fairly new to coding HTML and CSS, and I'm looking for a starting point with responsive design that will help me finish a project I'm working on.
I have essentially used divs to create a two-column table (using div style="display: table;") and then divs for each column and row. In each row, there is an icon in the left column and text in the right column.
I understand the concept around media queries and have written the queries that I want based on screen sizes.
What I need help with is a starting point for what I need to write inside the queries - essentially resizing the divs and also displaying the divs differently (I imagine with floats) so that I can have the icons in the left column display above the icons in the right column. Basically, I want to stack the divs. I hope that makes sense. I'm not entirely sure where to start. I appreciate any and all help in advance.
Here's my HTML:
<div style="display: table;">
<!--First row-->
<div id="tr1" style="display: table-row;">
<div class="icon" style="display: table-cell;">
<img src="http://3.bp.blogspot.com/-E_DoZ3hZPZw/Uwl7yLn50_I/AAAAAAAAGr8/XpmeP14aphA/s1600/green.gif" width="300"></div>
<div class="words" style="display: table-cell;">
<h1>Text title</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sit amet fermentum arcu, elementum dapibus nulla. Donec quis libero in risus gravida rutrum. Vestibulum vitae.</p></div>
</div>
<!--Second row-->
<div id="tr2" style="display: table-row;">
<div class="icon" style="display: table-cell;">
<img src="http://upload.wikimedia.org/wikipedia/commons/0/0e/Ski_trail_rating_symbol-green_circle.svg" width="300"></div>
<div class="words" style="display: table-cell;">
<h1>Another text title</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sit amet fermentum arcu, elementum dapibus nulla. Donec quis libero in risus gravida rutrum. Vestibulum vitae.</p></div>
And here is my CSS:
.icon {position: relative; }
.words {position: static;
vertical-align: middle;}
/* Mobile: Max Size for Mobile Device */
#media (max-width: 639px){
}
Here's the basics of what I've done in This Fiddle:
Indented. Reading code that isn't indented is difficult, and leads to errors.
Removed inline styles.
Set the CSS for the third-level divs to be display: table-cell. Note that this selector should / could be replaced with a class instead.
Added the css to your media query to cause them to "stack" as requested.
Here's the revised code for your reference:
<!-- Removed the "display: table" - not necessary -->
<div>
<!--First row-->
<!-- Remove the "display: table-row" - not necessary -->
<div id="tr1">
<!-- Remove the "display: table-cell" - moved to css -->
<div class="icon">
<img src="http://3.bp.blogspot.com/-E_DoZ3hZPZw/Uwl7yLn50_I/AAAAAAAAGr8/XpmeP14aphA/s1600/green.gif" width="300">
</div>
<div class="words">
<h1>Text title</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sit amet fermentum arcu, elementum dapibus nulla. Donec quis libero in risus gravida rutrum. Vestibulum vitae.</p>
</div>
</div>
<!--Second row-->
<div id="tr2">
<div class="icon">
<img src="http://upload.wikimedia.org/wikipedia/commons/0/0e/Ski_trail_rating_symbol-green_circle.svg" width="300">
</div>
<div class="words" style="display: table-cell;">
<h1>Another text title</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sit amet fermentum arcu, elementum dapibus nulla. Donec quis libero in risus gravida rutrum. Vestibulum vitae.</p>
</div>
</div>
</div>
CSS:
/* this selects third-level divs */
div > div > div {
display: table-cell;
}
.icon {
position: relative;
}
.words {
vertical-align: middle;
}
/* Mobile: Max Size for Mobile Device */
#media (max-width: 639px) {
/* change the display to block for stacking */
div > div > div {
display: block;
}
}
It is all about rewriting. So here is something that could inspure you.
<div class="wrapper">
<!--First row-->
<div id="tr1" class="row">
<div class="icon">
<img src="http://3.bp.blogspot.com/-E_DoZ3hZPZw/Uwl7yLn50_I/AAAAAAAAGr8/XpmeP14aphA/s1600/green.gif"></div>
<div class="words">
<h1>Text title</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sit amet fermentum arcu, elementum dapibus nulla. Donec quis libero in risus gravida rutrum. Vestibulum vitae.</p></div>
</div>
<!--Second row-->
<div id="tr2" class="row">
<div class="icon">
<img src="http://upload.wikimedia.org/wikipedia/commons/0/0e/Ski_trail_rating_symbol-green_circle.svg"></div>
<div class="words">
<h1>Another text title</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sit amet fermentum arcu, elementum dapibus nulla. Donec quis libero in risus gravida rutrum. Vestibulum vitae.</p></div>
</div>
</div>
And the css:
.icon {
position: relative;
display: table-cell; }
.icon a img {
width: 300px;
}.words {
position: static;
vertical-align: middle;
display: table-cell;
}
.row {
display: table-row;
}
.wrapper {
display: table;
}
/* Mobile: Max Size for Mobile Device */
#media (max-width: 639px){
.wrapper,
.row,
.words,
.icon {
display: block;
}
.words,
.icon {
text-align: center;
}
.icon a img {
display: inline-block;
width: 100%;
max-width: 300px;
}
}
Hope it helps.
My HTML DOM is given below. I want to remove margin and padding for all h3 elements which is an immediate sibling of div (id=successor). I used adjacent sibling selector "+" to acheive this.
But im not getting the expected output. Please help me.
<style type="text/css">
div#successor {
display: block;
}
div#successor+h3 {
padding :0 !important;
margin :0 !important;
border: 1px solid red;
}
</style>
<div id="access">
<div class="profile clearfix">
<div id="successor" class="memeberDetails">
<h3>Personal</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam purus dolor, vulputate iaculis erat ut, pulvinar commodo orci.Cras ac lorem a lectus luctus vestibulum. Suspendisse odio ligula, fringilla ut ultrices sed, aliquam nec ligula. Praesent porttitor,</p>
<br />
<h3>Training</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam purus dolor, vulputate iaculis erat ut, pulvinar commodo orci.</p>
<br />
<h3>Contact</h3>
<p>Lorem ipsum dolor sit amet</p>
</div>
</div>
</div>
If you want to add styles to h3 elements you need to select them by:
div#successor>h3
Adjacent selector selects element next to the object on the left of '+' operator, so it will work if you have such structure:
<div id="successor" class="memeberDetails">
...
</div>
<h3>...</h3>
As IMSoP said #successor is the parent and you want to select its immediate child.
You might want to use : div#successor>h3
Here is a working example: http://jsfiddle.net/Au4Vh/