bottom align 3 responsive divs - css

I am a keen follower of this website and this is the first time I couldn't find what I was looking for. I hope someone can help me soon.
I have 3 divs inside a responsive container div. the middle div need to be vertically aligned to the bottom. How do I achieve that? Please help
CSS:
/* COLUMN LAYOUT GRID CSS */
/* SECTIONS */
.section {
clear: both;
padding: 0px;
margin: 0px;
}
.section img {
width: 100%;
}
/* COLUMN SETUP */
.col {
display: block;
float:left;
margin: 0 0 0 0;
}
#press-grid .col {
margin: 1% 0 1% 1.5%;
}
.col:first-child { margin-left: 0; }
/* GROUPING */
.group:before,
.group:after {
content:"";
display:table;
}
.group:after {
clear:both;
}
.group {
zoom:1; /* For IE 6/7 */
}
/* END OF GENERAL CSS */
/* GRID OF TWO */
#featured-slider {
}
#featured-right {
padding: 20px;
}
/* GRID OF THREE */
.span_3_of_3 {
width: 100%;
}
.span_2_of_3 {
width: 66.66%;
}
.span_1_of_3 {
width: 33.33%;
}
#press-grid .span_1_of_3 {
width: 31%;
background-color: white;
height: 500px;
}
/* GO FULL WIDTH AT LESS THAN 480 PIXELS */
#media only screen and (max-width: 798px) {
.col {
margin: 1% 0 1% 0%;
}
}
#media only screen and (max-width: 798px) {
.span_1_of_3 {
width: 100%;
}
.span_2_of_3 {
width: 100%;
}
.span_3_of_3 {
width: 100%;
}
.featured-slider {
width: 100%;
}
#featured-right {
height: 150px;
}
}
/* END COLUMN LAYOUT GRID CSS */
HTML:
<div class="content-section" id="cabin-mockup">
<div class="container">
<div class="row">
<div class="section group">
<div class="col span_1_of_3 text-center" id="home-mockup-left">
<p> </p>
<p>
<i class="fa fa-paper-plane-o"></i>
</p>
<h3>Cabin Mockup</h3>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec.</p>
<img src="/template/images/mockup2.jpg" alt="Aircraft Cabin Mockup" />
</div>
<div class="col span_2_of_3 text-center" id="home-mockup-right">
<img src="/template/images/mockup.jpg" alt="Aircraft Cabin Mockup" />
</div>
</div>
</div>
</div>
</div>

Try changing col to this:
.col {
display: table-cell;
vertical-align:bottom;
margin: 0 0 0 0;
}

Related

How do I achieve this effect with css (image)

image
So I have a div full of main article content with a width of 600px and I would like to have these links as well at the side, I imagine it would be in the same div but I can't seem to get the right effect and need some help with this.
Thanks a lot.
HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="stylesheets/style.css">
<!-- viewport meta to reset iPhone inital scale -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>title</title>
</head>
<body>
<div id="pagewrap">
<div id="logos">
<img id="logo" src="img/logo.png">
<h1 id="name">Company Name</h1>
<img class="socialmedia" src="img/facebook.png">
<img class="socialmedia" src="img/twitter.png">
<img class="socialmedia" src="img/googleplus.png">
</div>
<div id="header">
<div id="menu-outer">
<div class="table">
<ul id="horizontal-list">
<li>Home</li>
<li>eBooks</li>
<li>Magazines</li>
<li>Movies</li>
<li>Help</li>
<li>Login</li>
</ul>
</div>
</div>
</div>
<div id="content">
<h2>Lorem Ipsum Dolor Sit</h2>
<p id="article-information">posted on 15 May 2015 by Author</p>
<img id="main-article-image" src="img/placeholder.png">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam fermentum. Integer
fringilla. Integer fringilla. Pellentesque acturpis. Sed elementum, felis quis porttitor
sollicitudin, augue nulla sodales sapien, amet posuere quam purus at lacus. Nam id neque. Morbipulvinar nulla sit amet nisl. Etiam pharetra lacus sed velit
imperdiet bibendum. ed quis elit. In hac habitasse platea dictumst. Maecenas
justo. Donec interdum vestibulum libero. Nam laoreet dui sed
magna. Nam consectetuer mollis dolor. Aenean ligula.
liquam sed erat. Donec interdum vestibulum libero. Mauriset dolor.</p>
<div id="more-links-list">
<p>list</p>
<p>items</p>
<p>lol</p>
</div>
</div>
<div id="sidebar">
<h3>A guide to snoopsetting</h3>
<img class="aside-images" src="img/placeholder.png">
<h3>Welcome to the Surveillance State</h3>
<img class="aside-images" src="img/placeholder.png">
</div>
<div id="footer">
</div>
</div>
</bo
dy>
CSS
body {
font: 1em/150% Arial, Helvetica, sans-serif;
}
a {
color: #669;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
#logo {
width: 20%;
height: auto;
position: relative;
right: 25px;
top: 50px;
}
#name {
position: relative;
bottom: 60px;
left: 170px;
font-style: italic;
font-size: 55px;
height: 30px;
}
.socialmedia {
position: relative;
width: 8%;
bottom: 155px;
height: auto;
float: right;
}
#main-article-image {
width: 600px;
height: 450px;
}
.aside-images {
width: 340px;
height: 255px;
}
#more-links-list {
display: inline;
}
/************************************************************************************
STRUCTURE
*************************************************************************************/
#pagewrap {
padding: 5px;
width: 960px;
margin-right: auto;
margin-left: auto;
}
#logos {
height: 160px;
}
#header {
height: 50px;
}
#content {
position: relative;
width: 600px;
float: left;
text-align: justify;
}
#more-links-list {
float:right;
padding: 10px;
margin-left:10px;
margin-bottom:10px;
background:#ddd;
}
#sidebar {
width: 340px;
float: right;
position: relative;
bottom: 34px;
}
#footer {
clear: both;
width: auto;
height: 100px;
}
#article-information {
margin: 0px;
}
h2 {
margin: 0px;
padding-top: 56px;
}
h3 {
margin: 0px;
padding-top: 38px;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
float: left;
width: 16.65%;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
/* Change the link color to #111 (black) on hover */
li a:hover {
background-color: #111;
}
/************************************************************************************
MEDIA QUERIES
*************************************************************************************/
/* for 980px or less */
#media screen and (max-width: 980px) {
#pagewrap {
width: 94%;
}
#content {
width: 65%;
}
#sidebar {
width: 30%;
}
}
/* for 700px or less */
#media screen and (max-width: 700px) {
#content {
width: auto;
float: none;
}
#sidebar {
width: auto;
float: none;
}
}
/* for 480px or less */
#media screen and (max-width: 480px) {
#header {
height: auto;
}
h1 {
font-size: 24px;
}
#sidebar {
display: none;
}
}
/* border & guideline (you can ignore these) */
#header, #content, #sidebar {
margin-bottom: 5px;
}
#footer {
background-color: #eee;
border-style: solid;
border-width: 1px;
}
You can do this by placing a div with float:right; style inside the div that holds your content (article text), I created this example for you:
https://jsfiddle.net/davoscript/tjf56jLw/4/
<p>
<!-- The floating box -->
<div id="more-links-list" style="float:right;">
<p>list</p>
<p>items</p>
<p>lol</p>
</div>
<!-- The article content -->
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam fermentum. Integer...
</p>
Let me know if that works.
You should probably put the links into an <aside>. This could go below the code for the text in your div and then styled with either a float or positioning. It would then be a matter of getting your styling to allow the text to wrap under the links.

CSS display: table-cell width 100% overflow-x expand

I have this two column layout, made with display: table and display: table-cell, and I want to put in the second column a div with horizontal scroll, but the table expands itself and the scroll goes to the entire page rather then the div.
HTML
<div class="wrapper">
<div id="one"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque convallis finibus metus. Suspendisse commodo rutrum sapien, eu faucibus metus. Nunc elementum augue eu aliquet condimentum.
</div>
<div id="two">
<div id="horizontal">
<img src="https://dl.dropbox.com/u/1218282/slideshow/1.jpg" />
<img src="https://dl.dropbox.com/u/1218282/slideshow/2.jpg" />
<img src="https://dl.dropbox.com/u/1218282/slideshow/3.jpg" />
<img src="https://dl.dropbox.com/u/1218282/slideshow/4.jpg" />
</div>
</div>
</div>
CSS
.wrapper {
display: table;
table-layout: fixed;
}
#one {
display: table-cell;
background-color: gray;
width: 200px;
}
#two {
display: table-cell;
width: 100%;
}
#horizontal {
width: 100%;
overflow-x: scroll;
white-space: nowrap;
}
#horizontal img {
max-width: 200px;
}
Here is the jsfiddle:
http://jsfiddle.net/cUCvY/2597/
In this example I'd like to have the horizontal scroll active on the div with the images inside and not on the page.
Hope i understood correctly:
.wrapper {
display: table;
table-layout: fixed;
width:100%
}
#one {
display: table-cell;
background-color: gray;
width: 200px;
}
#two {
}
#horizontal {
overflow-x: scroll;
white-space: nowrap;
}
#horizontal img {
max-width: 200px;
}
}
#media screen and (max-width: 400px) {
#one {
float: none;
margin-right:0;
width:auto;
border:0;
border-bottom:2px solid #000;
}
}
http://jsfiddle.net/cUCvY/2600/

Wanting to overlay a div over an image using flexbox

I have a series of scaling triangles that I've arranged using flexbox, they get bigger and smaller depending on how the window is stretched. I want to have these overlay the bottom of an image to give it a sort of ripped paper or mountain peak sort of effect. The image that they will overlay scales to fit the window and the triangles must follow the image, scaling up and down with the window.
I'm having a lot of difficulty coming up with a solution to this problem and could use some help.
This is how I want the triangles and image to look and relate to one another, the triangles being black in this screenshot and the image being grey.
http://i.imgur.com/KkXq9pc.png
Here's a jsfiddle link to the project: http://jsfiddle.net/wD2r2/
CSS:
.triangle-up {
margin: 0 auto;
width: 50%;
height: 0;
padding-left:50%;
padding-bottom: 50%;
overflow: hidden;
}
.triangle-up:after {
content: "";
display: block;
width: 0;
height: 0;
margin-left:-9999px;
border-left: 9999px solid transparent;
border-right: 9999px solid transparent;
border-bottom: 9999px solid #000000;
}
.triangle-container {
display: flex;
}
.overlay {
top: -100px;
left:0px;
right:0px;
z-index: 1;
position: relative;
margin-top: 10px;
}
HTML:
<div>
<div>
<img style="width:100%;" src="images/treeline.jpg" />
</div>
<article class="overlay">
<div class="triangle-container">
<article>
<div class="triangle-up" />
</article>
<article>
<div class="triangle-up" />
</article>
<article>
<div class="triangle-up" />
</article>
<article>
<div class="triangle-up" />
</article>
<article>
<div class="triangle-up" />
</article>
<article>
<div class="triangle-up" />
</article>
</div>
</article>
</div>
I want to avoid the effect of the triangles rising up or down or shifting along the sides of the window in relation to the image. I've been trying to get it to stay constantly running along the bottom and scaling appropriately but with no luck.
Thanks a bunch.
There is a bit to this, so I'll explain everything that I did in order.
1. Brown/Yellow bars' container
In order to get those two brown and yellow bars at the bottom, you need a container for them. Since there is black around them, I simply created a 100% x 40px div with a black background:
.bottom
{
background: black;
width: 100%;
height: 40px;
}
2. Create the brown and yellow bars
Since the brown and yellow bars are on the same line and are blocks, I created two inline-block elements with width 43% and one-side margins of 7%, as well as setting the proper background-color:
.brown, .yellow
{
display: inline-block;
width: 43%;
height: 20px;
margin: 20px 0 0 0;
}
.brown
{
background: brown;
margin-left: 7%;
}
.yellow
{
background: yellow;
margin-right: 7%;
}
3. Image border
Since you have that grey border around the image, I set the image box-sizing mode to border-box so that the image size would not change and I added 20px of padding to all of the sides. Then I set the background to grey to make the space around the image the right color:
img
{
padding: 20px;
box-sizing: border-box;
-moz-box-sizing: border-box;
background: #888;
}
JSFiddle
I made this flexbox text overlaying on an image
.wrapper {
display: flex;
flex-flow: row wrap;
font-weight: bold;
text-align: center;
}
.wrapper > * {
padding: 10px;
flex: 1 100%;
}
.header {
background: tomato;
}
.footer {
background: lightgreen;
}
.main {
text-align: left;
background: url(https://raw.githubusercontent.com/212mr/608m02SamsungS8/master/image/1482233503439.jpg) no-repeat 0 0;
background-size: cover;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
}
.aside-1 {
background: gold;
}
.aside-2 {
background: hotpink;
}
#media all and (min-width: 600px) {
.aside { flex: 1 auto; }
}
#media all and (min-width: 800px) {
.main { flex: 3 0px; }
.aside-1 { order: 1; }
.main { order: 2; }
.aside-2 { order: 3; }
.footer { order: 4; }
}
body {
padding: 2em;
}
<div class="wrapper">
<header class="header">Header</header>
<article class="main">
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
</article>
<aside class="aside aside-1">Aside 1</aside>
<aside class="aside aside-2">Aside 2</aside>
<footer class="footer">Footer</footer>
</div>
First, you need to make your flexbox.
Second, put the image (as a background image) into your flexbox child.
Third, put your text to overlay on the image.

CSS centered image with dynamic left and right div with lines

I want a fixed width image in the middle.
That is no problem.
But i want the left and right div beside it to be 2 lines.
Example.
I have a 100px * 100px image in the middle and want the 2 divs to be 50% - 50px in width without using calc. The 2 divs should have a line which is also no problem.
I just use
{ background: white; margin-top: 48px; margin-bottom: 48px; }
Now the problem is to make those 2 divs fill the left and right space of the image.
Needless to say the width of the entire screen is dynamic.
Is there anyway to do this only with CSS?
Here is my solution using a wrapper for the left and right div, which have a width of 50% and contain other divs with margins of half the image's width. The image itself is positioned in the wrapper using absolute positioning.
HTML
<div class="wrapper">
<div class="left"><div>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor.</div></div>
<div class="right"><div>Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</div></div>
<img src="your_image.png" alt="" />
</div>
CSS
.wrapper {
position: relative;
overflow: hidden;
height: auto; /* match the height of the floating divs */
}
.wrapper > div > div {
min-height: 100px; /* at least as high as the image */
}
.wrapper > .left {
float: left;
width: 50%;
}
.wrapper > .left > div {
margin-right: 50px;
background: blue;
}
.wrapper > .right {
float: right;
width: 50%;
}
.wrapper > .right > div {
margin-left: 50px;
background: red;
}
.wrapper > img {
position: absolute;
width: 100px;
height: 100px;
top: 0;
left: 50%;
margin-left: -50px;
}
Here is a JSFiddle: http://jsfiddle.net/j84LB/
You could try warpping it, and giving the divs on the sides 25% and the image 50%. This is the same as the divs having values 50% of the images width.
CSS
.wrapper {width: 200px;}
.left {width: 25%;}
.right {width:25%;}
.image {width: 50%;}
HTML
<div class="wrapper">
<div class="left"></div>
<div class="image">
<img src="" />
</div>
<div class="right"></div>
</div>
Seems easy using enough display:table/display:table-cell
No need to extra divs etc.
JSfiddle Demo
HTML
<body>
<div class="wrapper">
<div class="left">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor
</div>
<div><img src="http://lorempixel.com/output/abstract-q-c-100-100-6.jpg" alt="" /></div>
<div class="right">Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
</div>
</div>
</body>
CSS
.wrapper {
position: relative;
overflow: hidden;
height: auto;
display:table;
}
.wrapper > div {
display:table-cell;
vertical-align: middle;
padding: 1em;
}
.wrapper > div:nth-child(2) {
min-height: 100px;
width:100px;
padding:0;
}

center 3 divs in footer with dynamic with?

i got a tricky situation here. im trying to center 3 divs inside my footer and they need to have dynamic width, like min-width.
[cotainer [first] [second] [third] /container]
my setup is this
<footer>
<div id="container">
<div id="first"></div>
<div id="second"></div>
<div id="third"></div>
</div>
</footer>
footer #container { width: 800px; margin: 0 auto; }
#container #first,#container #second,#container #third
{
float: left;
min-width: 200px;
height: 25px;
background: /* image url */
padding: 4px;
margin: 0 20px 0 0;
}
#container #third { margin-right: 0; }
You should use display: table; and table-cell.
#container {
display:table;
}
#first, #second, #third {
display: table-cell;
width: 200px;
height: 40px;
border: 1px dashed #000;
}
Demo available here.
set container to display as:table and set it's margin to 0 auto.
#container {
display:table;
margn:0 auto;
whitespace: nowrap;
}
#first, #second, #third {
min-width: 200px;
float:left
...
}
Demo: http://jsfiddle.net/AZ4yT/1/
Edit: It gets left aligned in IE. so you might wanna use a workaround for that
What about using display: inline-block? You can see a jsFiddle of it here:
http://jsfiddle.net/S7bKT/1/
HTML
<div id="container">
<div id="first">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Aliquam scelerisque euismod auctor. Sed pulvinar nulla eu
lorem iaculis ultrices. Mauris
</div>
<div id="second">Lorem ipsum dolor sit amet</div>
<div id="third">Sed pulvinar nulla eu lorem iaculis ultrices</div>
</div>
CSS
#container {
width: 500px;
background: #dedede;
margin: 0 auto;
text-align: center;
}
#first, #second, #third {
display: inline-block;
min-width: 50px;
max-width: 120px;
min-height: 100px;
zoom: 1; /* Fix for IE */
_display: inline; /* Hack for IE */
margin-right: 20px;
vertical-align: top;
}
#first {
background: #f00;
}
#second {
background: #0f0;
}
#third {
background: #00f;
}
#container div:last-child {
margin-right: 0;
}

Resources