Stack divs vertically & keep 2 column layout - html

I want to have two stacked divs on one side, and then have a single column on the other side with the same height as the left divs.
Kind of like this:
I have the two divs and a side bar, but the two divs won't stack.
Here is what I have so far Fiddle
#import url(https://fonts.googleapis.com/css?family=Oxygen);
body {
background-color: #222;
}
.description h1 {
text-align: left;
padding: 20px;
}
#wrapper {
text-align: center;
}
.description,
.sidebar,
.demo-container {
display: inline-block;
vertical-align: top;
}
.description {
background: #eee;
width: 50%;
font-family: "Oxygen";
font-size: 14px;
color: #000;
line-height: 1.2;
}
.sidebar {
background: #eee;
width: 15%;
height: 575px;
}
.demo-container {
background: #eee;
width: 50%;
font-family: "Oxygen";
font-size: 14px;
color: #000;
line-height: 1.2;
}
<div id='wrapper'>
<div class="demo-container">
<h1>Title</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam pretium lorem nec tortor elementum.</p>
</div>
<div class="description">
<h1>Title</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam pretium lorem nec tortor elementum.</p>
</div>
<div class="sidebar">
</div>
</div>

you are complicating a lot, here is a basic demo of what you want using flexbox
*,
*::before,
*::after {
box-sizing: border-box
}
body {
margin: 0
}
.flex {
display: flex;
flex-basis: 100%
}
.fl {
flex: 1;
display: flex;
flex-direction: column;
margin: 0 5px;
justify-content: space-between
}
.flex-item {
border: 1px solid black
}
.flex-item:not(:first-of-type) {
margin: 10px 0 0
}
.sidebar {
border: 1px solid black;
}
<div class="flex">
<div class="fl">
<div class="flex-item">
<h1>Title</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam pretium lorem nec tortor elementum, et aliquam erat feugiat. Duis interdum enim vitae justo cursus pulvinar eu ac nulla. Donec consectetur vehicula turpis. Nunc laoreet tincidunt elit</p>
</div>
<div class="flex-item">
<h1>Title</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam pretium lorem nec tortor elementum, et aliquam erat feugiat. Duis interdum enim vitae justo cursus pulvinar eu ac nulla. Donec consectetur vehicula turpis. Nunc laoreet tincidunt elit
ultrices elementum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Curabitur augue magna, posuere id tortor vel, condimentum consectetur lacus. Pellentesque dui est, ornare vitae semper et, dapibus ut lacus.
Etiam sed porta dui. Phasellus non nisl eget dolor commodo imperdiet.</p>
</div>
</div>
<div class="fl sidebar"></div>
</div>

Just put <div class="sidebar"></div> before the other two divs, then float them all right. See fiddle https://jsfiddle.net/y71tkmtw/1/
.description,
.sidebar, .demo-container {
float: right;
margin: 40px;
}

Just add another <div> surrounding the 2 divs on the left-hand side, with float:left. Add float:right to the sidebar.
.left-container
{
width: 85%;
float:left;
}
.sidebar {
background: #eee;
width: 15%;
height: 575px;
float:right;
}
Fiddle: https://jsfiddle.net/dncgytef/2/

Related

Same Height between child and parent container without Flex

I have a section with two articles. I would like that child articles, at all times, get the height of the section, considering that height is auto.
If is possible, I would like to do it without flex.
#section1 {
width: 100%;
height: auto;
display: block;
min-height: 400px;
height: auto;
margin: 0;
padding: 0;
font-size: 18px;
font-family: 'Montserrat';
}
#section1 #article1_section1 {
display: inline-block;
width: 79%;
vertical-align: top;
}
#section1 #article2_section1 {
display: inline-block;
width: 20%;
background-color: #ffc727 !important;
color: #ffc727 !important;
vertical-align: top;
}
<section id="section1">
<article id="article1_section1">
<div class="container_section_m">
<h2 class="h2_m">What is Lorem Ipsum</h2>
<h3 class="h3_m">Lorem ipsum is simply dummy</h3>
<div class="basetitle_m"></div>
<div class="space_m"></div>
<h4 class="h4_m">Where can I get some?</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum non porttitor diam. Fusce ac justo id ante blandit malesuada sit amet ac lectus. <br> Praesent maximus non mauris ac pretium. Cras vestibulum quam ac lorem tincidunt venenatis.
Suspendisse vehicula sollicitudin orci vel lobortis. Sed quis enim iaculis, facilisis neque nec, dictum mi.</p>
<p>Sed euismod ante leo, vitae vehicula ex molestie quis. Aenean venenatis nibh nisi. Phasellus sagittis interdum mi a auctor.</p>
</div>
</article>
<article id="article2_section1">
-
</article>
</section>
Try below css.
#section1{
width:100%;
height:auto;
display:table;
min-height:400px;
height:auto;
margin:0;
padding:0;
font-size:18px;
font-family: 'Montserrat';
}
#section1 #article1_section1{
display:table-cell;
width:79%;
vertical-align: top;
}
#section1 #article2_section1{
display:table-cell;
width:20%;
background-color: #ffc727 !important;
color: #ffc727 !important;
vertical-align: top;
}
stackblitz demo: https://stackblitz.com/edit/web-platform-dr7imx
display: inline-block; replace display:table-cell; use it
#section1 {
width: 100%;
height: auto;
display: block;
min-height: 400px;
height: auto;
margin: 0;
padding: 0;
font-size: 18px;
font-family: 'Montserrat';
}
#section1 #article1_section1 {
display:table-cell;
width: 79%;
vertical-align: top;
}
#section1 #article2_section1 {
display:table-cell;
width: 20%;
background-color: #ffc727 !important;
color: #ffc727 !important;
vertical-align: top;
}
<section id="section1">
<article id="article1_section1">
<div class="container_section_m">
<h2 class="h2_m">What is Lorem Ipsum</h2>
<h3 class="h3_m">Lorem ipsum is simply dummy</h3>
<div class="basetitle_m"></div>
<div class="space_m"></div>
<h4 class="h4_m">Where can I get some?</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum non porttitor diam. Fusce ac justo id ante blandit malesuada sit amet ac lectus. <br> Praesent maximus non mauris ac pretium. Cras vestibulum quam ac lorem tincidunt venenatis.
Suspendisse vehicula sollicitudin orci vel lobortis. Sed quis enim iaculis, facilisis neque nec, dictum mi.</p>
<p>Sed euismod ante leo, vitae vehicula ex molestie quis. Aenean venenatis nibh nisi. Phasellus sagittis interdum mi a auctor.</p>
</div>
</article>
<article id="article2_section1">
-
</article>
</section>

Ensure image, header, paragraph and button remain level, with different length size for header and paragraph

What I am trying to achieve is all images the same level, all headers and paragraphs level no matter what length they are and a button after which as all in the same level... I am also trying to make a 9x9 grid, but as soon as I add more columns they start going next to each other not by the underneath...
.flex-container {
display: flex;
flex-wrap: nowrap;
}
.flex-container .box {
width: 50%;
margin: 10px;
text-align: center;
}
.container {
padding-top: 30px;
height: 300px;
text-align: center;
min-width: 280px;
height: 100%;
margin-left: 100px;
margin-right: 100px;
display: flex;
justify-content: space-between;
}
.box h2 {
text-align: center;
font-family: "Slabo 27px", serif;
font-size: 24px;
font-weight: 700;
text-align: center;
padding-left: 25px;
padding-right: 25px;
}
.box p {
text-align: center;
font-family: "Montserrat", sans-serif;
font-size: 19px;
text-align: center;
padding-left: 25px;
padding-right: 25px;
padding-bottom: 10px;
}
/* Responsive layout - makes the three columns stack on top of each other instead of next to each other */
#media screen and (max-width: 800px) {
.column {
text-align: center;
float: left;
width: 50%;
}
}
.button {
border: none;
color: white;
padding: 16px 32px;
text-align: center;
text-decoration: none;
font-size: 16px;
margin: 4px 2px;
-webkit-transition-duration: 0.3s;
/* Safari */
transition-duration: 0.3s;
cursor: pointer;
}
.button {
background-color: white;
color: black;
border: 2px solid #008CBA;
text-align: center;
padding-bottom: 20px;
width: 50%;
margin: auto;
align-self: flex-end;
}
.button:hover {
background-color: #008CBA;
color: white;
}
<div class="container">
<div class="flex-container">
<div class="box">
<a href="#">
<img src="http://via.placeholder.com/600x600" alt="" width="400" height="300" style="max-width:90%;height:auto;" />
</a>
<h2>Example Header</h2>
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod eget mi at cursus. Nam aliquet dolor eros, in varius diam tincidunt et. Curabitur porta nunc arcu, sed mattis felis interdum ut. </p>
<div>
Learn more
</div>
</div>
<div class="box">
<a href="#">
<img src="http://via.placeholder.com/600x600" alt="" width="400" height="300" style="max-width:90%;height:auto;" />
</a>
<h2>Longer example of a header blah </h2>
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod eget mi at cursus. Nam aliquet dolor eros, in varius diam tincidunt et. Curabitur porta nunc arcu, sed mattis felis interdum ut. Curabitur consequat non nunc et tempus. Mauris
porta orci augue, in sagittis eros semper rutrum. Nam in elit mattis, auctor enim a, tempus arcu. In interdum eu lorem sit amet ullamcorper.</p>
<div>
Learn more
</div>
</div>
<div class="box">
<a href="#">
<img src="http://via.placeholder.com/600x600" alt="" width="400" height="300" style="max-width:90%;height:auto;" />
</a>
<h2>another short example </h2>
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod eget mi at cursus. Nam aliquet dolor eros, in varius diam tincidunt et. Curabitur porta nunc arcu, sed mattis felis interdum ut. Curabitur consequat non nunc et tempus. Mauris
porta orci augue, in sagittis eros semper rutrum. Nam in elit mattis, auctor enim a, tempus arcu. In interdum eu lorem sit amet ullamcorper. Proin est ipsum, rutrum ac est ut, mollis mollis elit. Curabitur eget dolor gravida, rhoncus arcu eget,
rhoncus ante. Nulla rhoncus in mauris et consequat. </p>
<div>
Learn more
</div>
</div>
</div>
This is currently the best I have, I've got all images and header and text to be the same level but as soon as I have the buttons in level the headers or paragraphs wont be level... Any help on this would be amazing!
If you are ok to set some heights and some overflow: hidden; you could do this:
.flex-container {
display: flex;
flex-wrap: nowrap;
}
.flex-container .box {
width: 50%;
margin: 10px;
text-align: center;
}
.container {
padding-top: 30px;
height: 300px;
text-align: center;
min-width: 280px;
height: 100%;
margin-left: 100px;
margin-right: 100px;
display: flex;
justify-content: space-between;
}
.box h2 {
text-align: center;
font-family: "Slabo 27px", serif;
font-size: 24px;
font-weight: 700;
text-align: center;
padding-left: 25px;
padding-right: 25px;
/* ! */
overflow: hidden;
height: 3.6em;
}
.box p {
text-align: center;
font-family: "Montserrat", sans-serif;
font-size: 19px;
text-align: center;
padding-left: 25px;
padding-right: 25px;
margin-bottom: 40px;
/* ! */
overflow: hidden;
height: 12.6em;
}
/* Responsive layout - makes the three columns stack on top of each other instead of next to each other */
#media screen and (max-width: 800px) {
.column {
text-align: center;
float: left;
width: 50%;
}
}
.button {
border: none;
color: white;
padding: 16px 32px;
text-align: center;
text-decoration: none;
font-size: 16px;
margin: 4px 2px;
-webkit-transition-duration: 0.3s;
/* Safari */
transition-duration: 0.3s;
cursor: pointer;
}
.button {
background-color: white;
color: black;
border: 2px solid #008CBA;
text-align: center;
padding-bottom: 20px;
width: 50%;
margin: auto;
align-self: flex-end;
}
.button:hover {
background-color: #008CBA;
color: white;
}
/* ! */
.fade {
position: relative;
height: 3.6em;
}
/* ! */
.fade:after {
content: "";
text-align: right;
position: absolute;
bottom: 0;
right: 0;
width: 70%;
height: 1.2em;
background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1) 50%);
}
<div class="container">
<div class="flex-container">
<div class="box">
<a href="#">
<img src="http://via.placeholder.com/600x600" alt="" width="400" height="300" style="max-width:90%;height:auto;" />
</a>
<div>
<h2 class="fade">Example Header</h2>
<p class="fade"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod eget mi at cursus. Nam aliquet dolor eros, in varius diam tincidunt et. Curabitur porta nunc arcu, sed mattis felis interdum ut. </p>
</div>
<div>
Learn more
</div>
</div>
<div class="box">
<a href="#">
<img src="http://via.placeholder.com/600x600" alt="" width="400" height="300" style="max-width:90%;height:auto;" />
</a>
<h2 class="fade">Longer example of a header blah blah blah </h2>
<p class="fade"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod eget mi at cursus. Nam aliquet dolor eros, in varius diam tincidunt et. Curabitur porta nunc arcu, sed mattis felis interdum ut. Curabitur consequat non nunc et tempus. Mauris
porta orci augue, in sagittis eros semper rutrum. Nam in elit mattis, auctor enim a, tempus arcu. In interdum eu lorem sit amet ullamcorper.</p>
<div>
Learn more
</div>
</div>
<div class="box">
<a href="#">
<img src="http://via.placeholder.com/600x600" alt="" width="400" height="300" style="max-width:90%;height:auto;" />
</a>
<h2 class="fade">another short example </h2>
<p class="fade"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod eget mi at cursus. Nam aliquet dolor eros, in varius diam tincidunt et. Curabitur porta nunc arcu, sed mattis felis interdum ut. Curabitur consequat non nunc et tempus. Mauris
porta orci augue, in sagittis eros semper rutrum. Nam in elit mattis, auctor enim a, tempus arcu. In interdum eu lorem sit amet ullamcorper. Proin est ipsum, rutrum ac est ut, mollis mollis elit. Curabitur eget dolor gravida, rhoncus arcu eget,
rhoncus ante. Nulla rhoncus in mauris et consequat. </p>
<div>
Learn more
</div>
</div>
</div>
Flow fade thing is from here where you can also find some other approaches to your problem. Hope this helps.

Responsive 4 Column web layout HTML CSS DIVs

I am looking to build a simple website but I cannot seem to get the layout correct. Below are some images of what I am shooting for as well as my code.
Question: Does every column(4 total) become its own div. Is each row a div? Is each item a div? I am confused on that. Also wondering how containers and wrappers would apply here.
Code below.
<!DOCTYPE html>
<html lang="en-us">
<head>
<style>
/* SECTIONS */
.section {
clear: both;
padding: 0px;
margin: 0px;
}
/* COLUMN SETUP */
.col {
display: block;
float:left;
margin: 1% 0 1% 1.6%;
}
.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 */ }
/* GRID OF FOUR */
.span_4_of_4 {
width: 100%;
}
.span_3_of_4 {
width: 74.6%;
}
.span_2_of_4 {
width: 49.2%;
}
.span_1_of_4 {
width: 23.8%;
}
/* GO FULL WIDTH BELOW 480 PIXELS */
#media only screen and (max-width: 480px) {
.col { margin: 1% 0 1% 0%; }
.span_1_of_4, .span_2_of_4, .span_3_of_4, .span_4_of_4 { width: 100%; }
}
.header, .footer {
padding: 5px;
color: white;
background-color: black;
clear: left;
text-align: center;
}
.aboutus {
float:right;
margin: 5px;
padding: 5px;
width: 25%;
height: auto;
border: 1px solid black;
background-color:#123;
}
.aboutimage {
float:left;
margin: 5px;
padding: 5px;
width: 25%;
height: auto;
border: 1px solid black;
background-color:#123;
}
.about {
margin: 5px;
padding: 5px;
width: 100%;
height: 25%;
border: 1px solid black;
background-color:#989
}
.specials {
float: left;
margin: 10px;
padding: 10px;
width: 100%;
height: 300px;
border: 1px solid black;
background-color:#800;
}
.special1, .special2, .special3, .special4 {
margin: 1px;
padding: 1px;
width: 25%;
height: 50px;
border: 1px solid black;
background-color:#800;
}
.hours, .location {
margin: 5px;
padding: 5px;
width: 50%;
height: 150px;
border: 1px solid black;
background-color:#950;
}
.container{
float: center;
margin: auto;
padding: 10px;
width: 100%;
max-width: 1500px;
height: 1068px;
border: 1px solid red;
}
.logistics{
margin:1px;
padding:1px;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<p>Restaurant</p>
<p>A family restaurant</p>
<span>This is some text that is going to span this div.</span>
</div>
<div class="about">
<div class="aboutus">
<h2>About Us</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse eget risus nibh. Aenean imperdiet ex ac viverra porta. Nulla tempor lorem nec augue tristique, sed molestie ante mattis. Donec et lorem non nibh eleifend auctor. Mauris congue metus in suscipit tincidunt. Pellentesque sem ligula, viverra eu sem a, bibendum convallis dolor. Fusce viverra mattis lobortis.
</p>
</div>
<div class="aboutimage">
<h2>About Us</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse eget risus nibh. Aenean imperdiet ex ac viverra porta. Nulla tempor lorem nec augue tristique, sed molestie ante mattis. Donec et lorem non nibh eleifend auctor. Mauris congue metus in suscipit tincidunt. Pellentesque sem ligula, viverra eu sem a, bibendum convallis dolor. Fusce viverra mattis lobortis.
</p>
</div>
</div>
<div class="specials">
<div class="chicken">
<h2>About Us</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse eget risus nibh. Aenean imperdiet ex ac viverra porta. Nulla tempor lorem nec augue tristique, sed molestie ante mattis. Donec et lorem non nibh eleifend auctor. Mauris congue metus in suscipit tincidunt. Pellentesque sem ligula, viverra eu sem a, bibendum convallis dolor. Fusce viverra mattis lobortis.
</p>
</div>
<div class="pork">
<h2>About Us</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse eget risus nibh. Aenean imperdiet ex ac viverra porta. Nulla tempor lorem nec augue tristique, sed molestie ante mattis. Donec et lorem non nibh eleifend auctor. Mauris congue metus in suscipit tincidunt. Pellentesque sem ligula, viverra eu sem a, bibendum convallis dolor. Fusce viverra mattis lobortis.
</p>
</div>
</div>
<div class="section group">
<div class="col span_1_of_4">
<p>This is some text</p>
</div>
<div class="col span_1_of_4">
<p>This is some text</p>
</div>
<div class="col span_1_of_4">
<p>This is some text</p>
</div>
<div class="col span_1_of_4">
<p>This is some text</p>
</div>
</div>
<div class="logistics">
<div class="hours">
<h2>Hours of operation</h2>
<p>Monday through Sunday</p>
<p>7:00 AM - 7:00 PM</p>
</div>
<div class="location">
<h2>Location</h2>
<p></p>
<p></p>
</div>
</div>
<div class="footer">Copyright © KR</footer> </div>
</body>
</html>
To better understand how grid / divs / layout works maybe looking into Bootstrap documentation about Grids will help you. http://getbootstrap.com/css/#grid
Usually you have a .row that has .col (columns), like this:
<div class="row">
<div class="col-md-3">25% of the row</div>
<div class="col-md-3">25% of the row</div>
<div class="col-md-3">25% of the row</div>
<div class="col-md-3">25% of the row</div>
</div>
Yes. To accomplish the responsive behavior the columns must be each one an independent div. But, why don't you use Bootstrap or Foundation or some other CSS framework. Instead of trying to reinvent the wheel just use an existing one. Those frameworks will do the work for you.

Why is the paragraph not floating beside the profilePic?

Somehow, the paragraph is not floating beside the profilePic. It starts from the bottom of the profilePic. I am not able to understand why.
What is the mistake here?
.content {
margin-top: 30px;
margin-left: 20px;
padding-bottom: 20px;
}
.infoBit {
width: 800px;
float: left;
display: inline-block;
font-size: 1.1em;
padding-right: 10px;
padding-top: 10px;
}
.profilePic {
border: 1px blue solid;
height: 49px;
display: inline-block;
width: 49px;
float: left;
}
.infoText {
display: inline-block;
float: left;
}
<div class="content">
<div class="infoBit">
<div class="profilePic"></div>
<div class="infoText">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam quis enim ut sapien sodales commodo. Fusce congue, elit a finibus fermentum, diam eros mollis massa, at eleifend sapien dui eget mauris. Donec nec diam enim. Vivamus commodo placerat risus
vitae auctor. Cras leo elit, egestas eget dolor vitae, facilisis consequat sem. Mauris facilisis ipsum in porttitor ullamcorper. Nam vel massa sed quam venenatis facilisis. Quisque vitae mollis urna. In egestas nunc sed felis consequat, in malesuada
dolor feugiat. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</p>
</div>
</div>
</div>
https://jsfiddle.net/4sbzos1r/
It works fine even if is wrapped inside a . Defining width of resolves issue
Please change styles as below
.content
{
margin-top : 30px;
margin-left: 20px;
padding-bottom: 20px;
}
.infoBit
{
width: 800px;
/* float: left; */
display: inline-block;
font-size: 1.1em;
padding-right: 10px;
padding-top: 10px;
}
.profilePic
{
border:1px blue solid;
height: 49px;
display: inline-block;
width: 49px;
float: left;
}
.infoText
{
display: inline-block;
width: 700px;
}
As others have mentioned, it is because you have your <p> wrapped in a <div> with class infoText, which applies the styling display: inline-block; float:left; from the css you wrote. I would suggest either taking out the <div> entirely, or just remove the infoText styling you have. Furthermore, you probably want margin-top:0 on .infoText to bring the text to the top.
Does that make sense?
hope this help you
.content
{
margin-top : 30px;
margin-left: 20px;
padding-bottom: 20px;
}
.infoBit
{
width: 800px;
float: left;
display: inline-block;
font-size: 1.1em;
padding-right: 10px;
padding-top: 10px;
}
.profilePic
{
border:1px blue solid;
height: 49px;
display: inline-block;
width: 49px;
float: left;
}
.infoText
{
display: inline-block;
width:250px
}
.infoText p{
margin-top:0
}
<div class="content">
<div class="infoBit">
<div class="profilePic"></div>
<div class="infoText">
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam quis enim ut sapien sodales commodo. Fusce congue, elit a finibus fermentum, diam eros mollis massa, at eleifend sapien dui eget mauris. Donec nec diam enim. Vivamus commodo placerat risus vitae auctor. Cras leo elit, egestas eget dolor vitae, facilisis consequat sem. Mauris facilisis ipsum in porttitor ullamcorper. Nam vel massa sed quam venenatis facilisis. Quisque vitae mollis urna. In egestas nunc sed felis consequat, in malesuada dolor feugiat. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</p>
</div>
</div>
</div>

Text out of limit of box in Css

In the follwing example the text goes out of the box. And when I reduce the size of the borowser the size of the boxes shring resposively but the text becomes mixed and unorganized. How can solve this?
<html>
<head>
<meta charset="utf-8">
<title>This is an email template</title>
<style>
body {
background-color: rgba(79, 183, 227, 0.4);
direction: rtl;
}
body * {
font-family: Tahoma;
}
a:link {
text-decoration: none;
margin-right: 25px;
color: #46B1F9;
}
#wrap {
background-color: #e0f2f6;
margin: auto;
width: 75%;
padding: 15px;
border: 1px solid grey;
}
.item {
border: 1px solid #95A5A6;
border-radius: 5px;
margin-bottom: 25px;
width: 60%;
display: inline-block;
}
.item p {
font-size: 1em;
}
.item img {
float: left;
width: 30%;
}
.item .notice {
text-align: center;
float: right;
padding-top: 25px;
padding-right: 25px;
width: 50%;
height: 1em;
}
/*clearfixes*/
.clearfix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
.clearfix {
display: inline-block;
}
/* Hides from IE-mac \*/
* html .clearfix {
height: 1%;
}
.clearfix {
display: block;
}
/* End hide from IE-mac */
</style>
</head>
<body>
<div id="wrap">
<div style="padding:15px;">
<div class="item clearfix">
<div class="notice">
<p><strong>Lorem ipsum</strong>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam rhoncus sollicitudin aliquet. Fusce dolor leo, egestas non nisi in, aliquam ullamcorper diam. Quisque placerat tortor in porta egestas. Aenean et elementum purus. Nunc eget nulla blandit, volutpat libero non, finibus purus. Vivamus vitae tellus at risus commodo varius.</p>
</div>
<img src="http://s14.postimg.org/wqzq39iht/image.jpg" alt="" />
</div>
<div class="item clearfix">
<div class="notice">
<p>
<strong>اLorem ipsum</strong> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam rhoncus sollicitudin aliquet. Fusce dolor leo, egestas non nisi in, aliquam ullamcorper diam. Quisque placerat tortor in porta egestas. Aenean et elementum purus. Nunc eget nulla blandit, volutpat libero non, finibus purus. Vivamus vitae tellus at risus commodo varius.</p>
</div>
<img src="http://s10.postimg.org/y4kk17q21/image.jpg" alt="" />
</div>
<div class="item clearfix">
<div class="notice">
<p><strong>Lorem ipsum</strong>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam rhoncus sollicitudin aliquet. Fusce dolor leo, egestas non nisi in, aliquam ullamcorper diam. Quisque placerat tortor in porta egestas. Aenean et elementum purus. Nunc eget nulla blandit, volutpat libero non, finibus purus. Vivamus vitae tellus at risus commodo varius.</p>
</div>
<img src="http://s3.postimg.org/xca6ju1kj/image.jpg" alt="" />
</div>
</div>
</div>
</div>
</div>
</body>
</html>
If you are trying to expand the block by content, removing height from .item .notice should fix the issue.
In all cases your text will overflow the box , so you should add overflow:scroll to notice class
Depends on what you are trying to do.
If the boxes must be a fixed height there are couple of different strategies.
The easiest thing to do is to turn off the height restriction to the notice class. However, this will reflow your document and push everything down.
On the other hand, if you want to keep the current layout, I cannot provide you a unilateral decision as the padding, height and overflow will conflict with each other on this element.