How to properly size images within a div using flexbox? - html

this is how I want the final organization to lookI have two images and some text, I cannot sort out how to properly situate them so that the image on the left is smaller and also so that the entire div moves with my page when it's scaled up and down
HTML:
<div class="container">
<!-- ------------------------------ Section 1 ------------------------------ -->
<section class="sec-1">
<img class="img-1" src="./images/image-1.jpeg" alt="blue van driving on a highway at the base of a mountain.">
<div class="feature-box-1">
<img class="img-2" src="./images/image-2.jpeg" alt= "small row boat, aerial view, large body of water.">
<h4>FEATURE</h4>
<h2>Lorem ipsum dolor sit amet, consectetur.</h2>
<a class="button" href="#">read more</a>
</div>
</section>
CSS:
/* -------------------------------- Section 1 ------------------------------- */
.container {
margin: 0 auto;
max-width: 1100px;
width: 85%;
}
.sec-1 {
border: 5px solid red;
display: flex;
margin-top: 125px;
margin-bottom: 25px;
}
.feature-box-1 {
background:#F6F8FA;
margin-left: 35px;
text-align: center;
}
.img-1 {
max-height: 650px;
height: 100%;
}
.img-2 {
width: 100%;
height: auto;
}
.sec-1 h4 {
color: #777777;
}
.sec-1 h2 {
font-size: 39px;
}

You just need to put them in containers for example .aside-left .aside-right and inside .aside-right you can add container .top and .bottom
<style>
/* -------------------------------- Section 1 ------------------------------- */
.container {
display: flex;
width: 70%;
margin: auto;
height: 600px;
justify-content: center;
align-items: center;
border: 1px solid red;
}
.aside-left {
display: flex;
width: 30%;
height: 100%;
}
.aside-right {
margin-left: 2%;
width: 68%;
height: 100%;
border: 1px solid red;
}
.aside-left img {
width: 100%;
height: 100%;
}
.aside-right .top {
width: 100%;
height: 45%;
}
.aside-right .bottom {
width: 100%;
height: 55%;
}
.sec-1 h4 {
color: #777777;
}
.sec-1 h2 {
font-size: 39px;
}
</style>
<div class="container">
<!-- ------------------------------ Section 1 ------------------------------ -->
<section class="aside-left">
<img class="img-1" src="" alt="blue van driving on a highway at the base of a mountain.">
</section>
<section class="aside-right">
<div class="top">
<img class="img-2" src="./images/image-2.jpeg" alt="small row boat, aerial view, large body of water.">
</div>
<div class="bottom">
<h4>FEATURE</h4>
<h2>Lorem ipsum dolor sit amet, consectetur.</h2>
<a class="button" href="#">read more</a>
</div>
</section>
</div>

Related

Card container display: flex not working due to margin size issues

I have run into this problem I just can't fix and I believe it is due to the margin being so big.
The problem is that I would like 3 images beside each other on my website but they don't want to be next to each other because I believe the margin is so big.
I am very new to coding sorry if I'm missing something.
body {
background-color: AliceBlue;
font-family: "Helvetica", sans-serif;
color: black;
}
.arms {
height: 300px;
border-radius: 10px;
left: 300px;
}
#imgarms {
left: 300px;
}
a {
display: block;
width: 400px;
height: 320px;
border: 2px solid #F0FFFF;
border-radius: 10px;
box-sizing: border-box;
padding: 10px;
margin-top: 50px;
margin-left: auto;
margin-right: auto;
z-index: 10;
}
a:hover {
border-color: black;
}
.title {
position: absolute;
left: -20px;
}
.title {
position: relative;
margin-left: auto;
margin-right: auto;
left: -30;
}
#title {
width: 800px;
height: 400px;
margin-left: auto;
margin-right: auto;
z-index: 0;
}
.abs {
height: 300px;
border-radius: 10px;
left: 300px;
}
.shoulders {
height: 300px;
border-radius: 10px;
left: 300px;
}
.back {
height: 300px;
border-radius: 10px;
left: 300px;
}
.legs {
height: 300px;
border-radius: 10px;
left: 300px;
}
.chest {
height: 300px;
border-radius: 10px;
left: 300px;
}
.cardContainer {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
padding: 10px;
}
<body>
<div id="title" class="title">
<img id="title" class="title" src="https://trinket-user-assets.trinket.io/4e936b48ef16b9730de36cbbaec1c6c1e4988efc-5ea104f02cc0c3264f51231e.png" alt="title" />
</div>
<div class="cardContainer">
<a href="arms.html#scBarnowl">
<article class="card">
<img src="https://trinket-user-assets.trinket.io/8c41ed921e47afbbd3c097a06f8d44186fabf24e-5e9faf172cc0c3264f47ec6b.png" class="arms">
</article>
</a>
<a href="abs.html#scBarnowl">
<article class="card">
<img src="https://trinket-user-assets.trinket.io/8a1dbd5f8fcbc27772e44b9edadb3eea4d5f8e3d-5e9faf172cc0c3264f47ec6a.png" class="abs">
</article>
</a>
<a href="shoulders.html#scBarnowl">
<article class="card">
<img src="https://trinket-user-assets.trinket.io/6ba09699551ac1bc979673bbf99fee75b4064d10-5e9faf182cc0c3264f47ec71.png" class="shoulders">
</article>
</a>
<a href="back.html#scBarnowl">
<article class="card">
<img src="https://trinket-user-assets.trinket.io/a6776f95e6b7868be91d5aa0e89710e64e62fff8-5e9faf182cc0c3264f47ec6d.png" class="back">
</article>
</a>
<a href="legs.html#scBarnowl">
<article class="card">
<img src="https://trinket-user-assets.trinket.io/b628c0bca25058c3dac2cffcaff1ae4552522e7e-5e9faf182cc0c3264f47ec70.png" class="legs">
</article>
</a>
<a href="chest.html#scBarnowl">
<article class="card">
<img src="https://trinket-user-assets.trinket.io/373f3cbc6207fa4f67b4bcccb42f3b344c3fd10b-5e9faf182cc0c3264f47ec6f.png" class="chest">
</article>
</a>
</div>
</body>
I assume that you are trying to stick the images on your main page together. This is caused by the margins on your a tags together with the justify-content: space-around; of the .cardContainer.
To make the images stick together, remove the margins in the a and change justify-content: center in .cardContainer.
Your code with my modifications is added below.
When you use justify-content: space-around; the remaining space that elements can't take, will be spread around the items. This is displayed in the image (and snippet) below. This has space between items even though there is no margin.
.item{
background: lightgreen;
border: 2px solid darkgreen;
width: 100px;
height: 100px;
}
.wrapper{
justify-content: space-around;
display: flex;
flex-wrap: wrap;
height: 300px;
width: 390px;
padding: 10px;
background: lightblue;
border: 2px dotted darkblue;
}
<div class="wrapper">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
When you use justify-content: center; instead, the remaining space where elements can't go will only be added to the left and to the right of the content. So it gets centered and there will be no space inbetween the items (except if you set a margin or padding).
.item{
background: lightgreen;
border: 2px solid darkgreen;
width: 100px;
height: 100px;
}
.wrapper{
justify-content: center;
display: flex;
flex-wrap: wrap;
height: 300px;
width: 390px;
padding: 10px;
background: lightblue;
border: 2px dotted darkblue;
}
<div class="wrapper">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
Your modified code:
body {
background-color: orange;
}
body {
background-color: AliceBlue;
font-family: "Helvetica", sans-serif;
color: black;
}
nav ul {
background-color: tomato;
}
.arms {
height: 300px;
border-radius: 10px;
left: 300px;
}
#imgarms {
left: 300px;
}
a {
display: block;
width: 400px;
height: 320px;
border: 2px solid #F0FFFF;
border-radius: 10px;
box-sizing: border-box;
/* remove this padding to make the images really stick together */
padding: 10px;
z-index:10;
}
a:hover {
border-color: black;
}
.title {
position: absolute;
left:-20px;
}
.title {
position: relative;
margin-left: auto;
margin-right: auto;
left:-30;
}
#title {
width: 800px;
height: 400px;
margin-left: auto;
margin-right: auto;
z-index: 0;
}
.abs {
height: 300px;
border-radius: 10px;
left: 300px;
}
.shoulders {
height: 300px;
border-radius: 10px;
left: 300px;
}
.back {
height: 300px;
border-radius: 10px;
left: 300px;
}
.legs {
height: 300px;
border-radius: 10px;
left: 300px;
}
.chest {
height: 300px;
border-radius: 10px;
left: 300px;
}
.cardContainer {
display: flex;
flex-wrap: wrap;
justify-content: center;
padding: 10px;
}
/**********************************
This section is for styling tables
***********************************/
table, th, td {
border: 1px solid HoneyDew;
border-collapse: collapse;
}
tr {
background-color: PaleTurquoise;
}
th, td {
vertical-align: top;
padding: 5px;
text-align: left;
}
th {
color: purple;
}
td {
color: purple;
}
/********************************/
<!DOCTYPE html>
<html>
<head>
<title>Get Fit</title>
<link type="text/css" rel="stylesheet" href="styles.css"/>
<meta charset="utf-8"/>
</head>
<body>
<header>
</header>
<main>
<div id="title" class="title">
<img id="title" class="title" src="https://trinket-user-assets.trinket.io/4e936b48ef16b9730de36cbbaec1c6c1e4988efc-5ea104f02cc0c3264f51231e.png" alt="title" />
</div>
<div class="cardContainer">
<a href="arms.html#scBarnowl">
<article class="card">
<img src="https://trinket-user-assets.trinket.io/8c41ed921e47afbbd3c097a06f8d44186fabf24e-5e9faf172cc0c3264f47ec6b.png" class="arms">
</article>
</a>
<a href="abs.html#scBarnowl">
<article class="card">
<img src="https://trinket-user-assets.trinket.io/8a1dbd5f8fcbc27772e44b9edadb3eea4d5f8e3d-5e9faf172cc0c3264f47ec6a.png" class="abs">
</article>
</a>
<a href="shoulders.html#scBarnowl">
<article class="card">
<img src="https://trinket-user-assets.trinket.io/6ba09699551ac1bc979673bbf99fee75b4064d10-5e9faf182cc0c3264f47ec71.png" class="shoulders">
</article>
</a>
<a href="back.html#scBarnowl">
<article class="card">
<img src="https://trinket-user-assets.trinket.io/a6776f95e6b7868be91d5aa0e89710e64e62fff8-5e9faf182cc0c3264f47ec6d.png" class="back">
</article>
</a>
<a href="legs.html#scBarnowl">
<article class="card">
<img src="https://trinket-user-assets.trinket.io/b628c0bca25058c3dac2cffcaff1ae4552522e7e-5e9faf182cc0c3264f47ec70.png" class="legs">
</article>
</a>
<a href="chest.html#scBarnowl">
<article class="card">
<img src="https://trinket-user-assets.trinket.io/373f3cbc6207fa4f67b4bcccb42f3b344c3fd10b-5e9faf182cc0c3264f47ec6f.png" class="chest">
</article>
</a>
</div>
</main>
<footer>
</footer>
</body>
</html>

Putting two divs on the same row makes the first one start lower than it should be

I am trying to have 2 divs on the same row, one with a title and a <hr> and the other one with an image that can be clicked to go to another page(even if I remove the link the problem persists). My expectations would be that executing this code I would get the first one starting in the top left corner followed on right by the image, but instead the first <div> just starts randomly.
#zonaTitlu {
width: 300px;
height: 200px;
display: inline-block;
background-color: red;
}
#zonaImagine {
width: 400px;
height: 400px;
display: inline-block;
}
.LinieTitlu {
display: block;
margin-top: 0.5em;
margin-bottom: 0.5em;
margin-left: auto;
margin-right: 50px;
border-style: inset;
border-width: 2px;
border-color: darkgrey;
}
.logo {
width: 400px;
height: auto;
}
<body style="background-color:LightGray">
<div id="zonaTitlu">
<p>
<h3>Welcome to LOL Tournaments</h3>
</p>
<hr class="LinieTitlu">
</div>
<div id="zonaImagine">
<a href="https://eune.leagueoflegends.com/ro/">
<img class="logo" src="lol-logo.jpg" alt="LOL logo">
</a>
</div>
</body>
If you want both div side by side mean try this and change the image width to 100%
.zona{
width: 100%;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
#zonaTitlu {
width: 50%;
height: 200px;
display: inline-block;
background-color: red;
}
#zonaImagine {
width: 50%;
height: 400px;
display: inline-block;
}
.LinieTitlu {
display: block;
margin-top: 0.5em;
margin-bottom: 0.5em;
margin-left: auto;
margin-right: 50px;
border-style: inset;
border-width: 2px;
border-color: darkgrey;
}
.logo {
width: 400px;
height: auto;
}
<body style="background-color:LightGray">
<div class="zona">
<div id="zonaTitlu">
<h3>Welcome to LOL Tournaments</h3>
<hr class="LinieTitlu">
</div>
<div id="zonaImagine">
<a href="https://eune.leagueoflegends.com/ro/">
<img class="logo" src="lol-logo.jpg" alt="LOL logo">
</a>
</div>
</div>
</body>
While I like the other solutions (flexbox especially). OP seems to have a simple problem to fix - inline-block alignment default to baseline (bottom) and the content within the first div is what's being aligned with the bottom of the image. You see the hr is lined up with the bottom of the image.
Adding vertical-align: top; on either inline-block element fixes this and they will align at the top. Here is a good SO post on all the above behavior:
My inline-block elements are not lining up properly
I don't know what you're trying to do with fixed widths so I'm not going to offer other solutions with responsive design and whatnot - this is the straight answer to your question.
#zonaTitlu {
width: 200px;
height: 200px;
display: inline-block;
background-color: red;
vertical-align: top; // added this
}
#zonaImagine {
width: 140px;
height: 100px;
display: inline-block;
}
.LinieTitlu {
display: block;
margin-top: 0.5em;
margin-bottom: 0.5em;
margin-left: auto;
margin-right: 50px;
border-style: inset;
border-width: 2px;
border-color: darkgrey;
}
.logo {
width: 400px;
height: auto;
}
<body style="background-color:LightGray">
<div id="zonaTitlu">
<p>
<h3>Welcome to LOL Tournaments</h3>
</p>
<hr class="LinieTitlu">
</div>
<div id="zonaImagine">
<a href="https://via.placeholder.com/350x150">
<img class="logo" src="https://via.placeholder.com/140x100" alt="LOL logo">
</a>
</div>
Now you can adjust all things separately. TH HR is a bit outdated. It also will force a line break. I add a underline to the h3 which would do same i thing. But for completeness i add also a HR which can now be placed also individual by css.
Same for the image. - It depends a bit on the image size how to do adjustments.
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<style>
#zonaTitlu {
width: 400px;
height: 200px;
display: inline-block;
background-color: red;
display: inline-block;
position: absolute;
top: 0px;
left: 0px;
z-index: -1;
}
#zonaImagine {
width: 400px;
height: 400px;
display: inline-block;
}
.LinieTitlu {
display: block;
margin-top: 0.5em;
margin-bottom: 0.5em;
margin-left: auto;
margin-right: 50px;
border-style: inset;
border-width: 2px;
border-color: darkgrey;
}
.underlined {
text-decoration: underline;
}
.logo {
position: relative;
width: 400px;
height: auto;
top: 5px;
}
.spacer {
display: inline-block;
width: 30px;
}
.hr {
position: relative;
top: 60px;
width: 400px;
left: 0px"
}
.para {
position: relative;
width: 380px;
top: 15px;
}
</style>
<style type="text/css">
body.c1 {
background-color: LightGray
}
</style>
</head>
<body class="c1">
<h3 class="underlined">Welcome to LOL Tournaments <a class="logo" href="https://eune.leagueoflegends.com/ro/"><img class="logo" src="lol-logo.jpg" alt="LOL logo"></a></h3>
<div id="zonaTitlu">
<hr class="hr">
</div>
<p class="para">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Tu autem, si
tibi illa probabantur, cur non propriis verbis ea tenebas? Mihi enim satis est, ipsis non satis. <i>Eiuro,
inquit adridens, iniquum, hac quidem de re;</i> Duo Reges: constructio interrete.</p>
</body>
</html>
Looks right to me . You can try using a table if required.The div can be removed
here is a working example using flex-box
<body style="background-color:LightGray">
<div id="container">
<div id="zonaTitlu" class="box">
<p>
<h3>Welcome to LOL Tournaments</h3>
</p>
<hr class="LinieTitlu">
</div>
<div id="zonaImagine" class="box">
<a href="https://eune.leagueoflegends.com/ro/">
<img class="logo" src="lol-logo.jpg" alt="LOL logo">
</a>
</div>
</div>
</body>
<style>
/*
#zonaTitlu {
width: 300px;
height: 200px;
display: inline-block;
background-color: red;
}
#zonaImagine {
width: 400px;
height: 400px;
display: inline-block;
}
*/
#container {
display: flex;
flex-direction: row;
}
.box {
width: 400px;
height: 400px;
border: 1px solid black;
}
.LinieTitlu {
display: block;
margin-top: 0.5em;
margin-bottom: 0.5em;
margin-left: auto;
margin-right: 50px;
border-style: inset;
border-width: 2px;
border-color: darkgrey;
}
.logo {
width: 400px;
height: auto;
}
</style>

Positioning text in flexbox under pictures

I'm experiencing an issue with my text where I don't see it at all, or it doesn't act as though I would think it would in a flexbox. I have three images in the flexbox right now, but I would like to place small 'captions' under each of them(not in the p element, the purple, but I would like to place it on the white, which is right under the purple box(the p element). I thought that by adding a child element, that element would at least line up vertically with the element above it but I guess I'm wrong. Can anyone help? Another piece of info is that really my images are 250 pixels, but I wanted to accommodate for a snippet so I made it 50 pixels, but that's probably irrelevant.
#footer {
display: flex;
height: 130px;
width: 100%;
background-color: #862d59;
clear: both;
}
#footer, #wrapper:after{
height: 130px;
}
.wrap {
margin: 0 auto;
width: 100%;
display: flex;
align-items: center;
flex-wrap: nowrap;
}
.sub {
padding: 12px;
width: 32%;
height: 100px;
color: white;
border-right: solid white 1px;
}
.sub:last-child {
border: 0px;
}
html {
height: 100%;
}
body {
height: 100%;
margin:0;
font-family: courier;
font-size: 22px;
color: white;
}
#wrapper {
position: relative;
margin-left: auto;
margin-right: auto;
width: 85%;
min-height: 100%;
margin-top: -130px;
}
#inner {
position:absolute;
display:flex;
flex-wrap: wrap;
height: 600px;
top:50%;
align-items: center;
justify-content: space-between;
margin-top: -300px;
align-content: center;
width: 100%;
}
#inner p {
background-color: #26004d;
padding: 60px;
border-radius: 9px;
}
#inner img {
border-radius: 8px;
}
<div id="wrapper">
<div id="inner">
<p><img src="cat1.jpeg" alt="Picture of a cat" width="50" height="50"></p>
<p><img src="dog1.jpg" alt="Picture of a cat" width="50" height="50"></p>
<p><img src="park.jpg" alt="Picture of a cat" width="50" height="50"></p>
</div>
</div>
<div id="footer">
<div class="wrap">
<div class="sub"></div>
<div class="sub"></div>
<div class="sub"></div>
</div>
</div>
Without additional info / image, here's the solution I was able to come up with. If you want to keep each image / caption grouped together, wrap them in another parent div. Then just add the caption below that, which is a block element and should flow below the image, as intended. Snippet below.
#footer {
display: flex;
height: 130px;
width: 100%;
background-color: #862d59;
clear: both;
}
#footer, #wrapper:after{
height: 130px;
}
.wrap {
margin: 0 auto;
width: 100%;
display: flex;
align-items: center;
flex-wrap: nowrap;
}
.sub {
padding: 12px;
width: 32%;
height: 100px;
color: white;
border-right: solid white 1px;
}
.sub:last-child {
border: 0px;
}
html {
height: 100%;
}
body {
height: 100%;
margin:0;
font-family: courier;
font-size: 22px;
color: white;
}
#wrapper {
position: relative;
margin-left: auto;
margin-right: auto;
width: 85%;
min-height: 100%;
}
#inner {
position:absolute;
display:flex;
flex-wrap: wrap;
height: 600px;
top:50%;
align-items: center;
justify-content: space-between;
margin-top: -300px;
align-content: center;
width: 100%;
}
#inner p {
background-color: #26004d;
padding: 60px;
border-radius: 9px;
}
#inner p.caption {
color: #000;
background-color: transparent;
border-radius: 0;
}
#inner img {
display: block;
border-radius: 8px;
}
<div id="wrapper">
<div id="inner">
<div class="image-wrapper">
<p>
<img src="http://placehold.it/100x100" alt="Picture of a cat">
</p>
<p class="caption">Caption</p>
</div>
<div class="image-wrapper">
<p>
<img src="http://placehold.it/100x100" alt="Picture of a cat">
</p>
<p class="caption">Caption</p>
</div>
<div class="image-wrapper">
<p>
<img src="http://placehold.it/100x100" alt="Picture of a cat">
</p>
<p class="caption">Caption</p>
</div>
</div>
</div>
<div id="footer">
<div class="wrap">
<div class="sub"></div>
<div class="sub"></div>
<div class="sub"></div>
</div>
</div>
Let me know if you have any questions, or if this doesn't satisfy your description.

Resizing image to fit <td> or div

I want to create the following layout:
where the blue block is an image and the red and green blocks contain vertically centered text. The container needs to have position:fixed, the image is sized dynamically so that its height is set to the height of the container and the red and green boxes are of equal height and fill the remainder of the container horizontally.
I initially tried using divs:
body {
padding: 0;
margin: 0;
border: 0;
}
.container {
height: 15vh;
width: 100vw;
position: fixed;
background-color: red;
}
.imgContainer {
height: 100%;
float: left;
}
.imgContainer img {
height: 100%;
}
.textContainer {
height: 100%;
background-color: yellow;
text-align: right;
display: table;
table-layout: fixed;
float: right;
}
.row1 {
height: 50%;
width: 100%;
display: table-row;
}
.row2 {
height: 50%;
background-color: blue;
display: table-row;
}
span {
display: table-cell;
vertical-align: middle;
}
<div class="container">
<div class="imgContainer">
<img src="http://ingridwu.dmmdmcfatter.com/wp-content/uploads/2015/01/placeholder.png" />
</div>
<div class="textContainer">
<div class="row1">
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
</div>
<div class="row2">
<span>More text.</span>
</div>
</div>
</div>
This worked fine for the image but I couldn't figure out how to get the red and green divs to fill the remaining width satisfactorily.
My second attempt was based around tables but, again, I don't seem to be able to get the widths correct:
body {
background-color: red;
padding: 0;
border: 0;
margin: 0;
}
div {
background-color: yellow;
height: 15vh;
width: 100vw;
position: fixed;
}
table {
height: 100%;
width: 100%;
background-color: blue;
border-collapse: collapse;
table-layout: fixed;
}
tbody {
height: 100%;
width: 100%;
background-color: purple;
}
tr {
height: 50%;
width: 100%;
background-color: green;
padding: 0;
}
tr:last-child {
background-color: yellow;
}
td {
height: 100%;
padding: 0;
white-space: nowrap;
}
td:last-child {
max-width: 100%;
}
img {
max-height: 100%;
display: block;
}
<div>
<table>
<tbody>
<tr>
<td rowspan="2">
<img src="http://ingridwu.dmmdmcfatter.com/wp-content/uploads/2015/01/placeholder.png" />
</td>
<td>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</td>
</tr>
<tr>
<td>
More text.
</td>
</tr>
</tbody>
</table>
</div>
I have also had problems ensuring that both red and green sections remain at 50% of the total height, regardless of content.
How can I get either of these to work? Or is there a completely different approach that can work?
You don't say what your target market is, but since in most my work I only have to worry about the latest browser versions, this answer makes use of the new CSS flexbox. If you need compatibility with older browsers, see the 2nd set of code below.
body {
padding: 0;
margin: 0;
border: 0;
}
.container {
height: 15vh;
width: 100vw;
position: fixed;
display: flex;
flex-direction: row;
justify-content: space-between;
}
.imgContainer {
height: 100%;
}
.imgContainer img {
height: 100%;
}
.textContainer {
height: 100%;
width: 100%;
}
.row1 {
background-color: red;
}
.row2 {
background-color: green;
}
.row1,
.row2 {
height: 50%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-end;
overflow: hidden;
}
<div class="container">
<div class="imgContainer">
<img src="http://ingridwu.dmmdmcfatter.com/wp-content/uploads/2015/01/placeholder.png" />
</div>
<div class="textContainer">
<div class="row1">
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
</div>
<div class="row2">
<span>More text.</span>
</div>
</div>
</div>
Below is a solution that works in older browsers, except IE9 and below where the text will not be properly centered vertically. If that's a concern, you might be able to find something that works on this page, but not knowing all your limitations, I was unable to select the right solution.
body {
padding: 0;
margin: 0;
border: 0;
}
.container {
height: 15vh;
width: 100vw;
position: fixed;
}
.imgContainer {
height: 100%;
float: left;
}
.imgContainer img {
height: 100%;
}
.textContainer {
height: 100%;
}
.row1 {
height: 50%;
background-color: red;
}
.row2 {
height: 50%;
background-color: green;
}
span {
right: 0; /* right-justify */
}
.row1 > span {
position: absolute;
top: 25%; /* put the top 25% down within .container - the first non-static ancestor element */
transform: translateY(-50%); /* nudge the line up half it's height */
}
.row2 > span {
position: absolute;
top: 75%;
transform: translateY(-50%);
}
<div class="container">
<div class="imgContainer">
<img src="http://ingridwu.dmmdmcfatter.com/wp-content/uploads/2015/01/placeholder.png" />
</div>
<div class="textContainer">
<div class="row1">
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
</div>
<div class="row2">
<span>More text.</span>
</div>
</div>
</div>

How to align 2 divs parallel to each other

I am trying to align to divs parallel from each other, but it is not lining up properly.
I have already tried a number of the solutions posted on the site, but none of them are working.
Any ideas on how to resolve this issue would be appreciated.
<section class="section">
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-10">
<div class="content">
<div class="wrapper">
<p class="content-media left">
<img src="http://lorempixel.com/g/400/200/" alt="">
</div>
<div>
<div class="col-xs-12">
<div class="float:right;width:45%;">
<p>Lorem Ipsum <em>Lorem</em>, Lorem impsum Lorem Ipsum Lorem Ipsum</em>.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
body {
font-family: georgia, "times new roman", times, serif
}
.container {
width: 100%;
}
.container p,
.container div img {
display: inline-block;
}
.container p {
width: 60%;
float: right;
}
.container div img {
width: 38%;
float: right;
}
.logo {
position:fixed;
bottom: 25px;
left: 0px;
height: 100px;
width: 300px;
}
p {
font-size: 18px;
line-height: 22px;
margin-right: 360px;
right: 100px;
}
.dropcap {
float: left;
font-size: 76px;
line-height: 76px;
margin: 0 15px 5px 0;
}
.section {
background-color: #fff;
position: relative;
z-index: 10;
}
.section-header {
margin-top: 50px
!important;
z-index: 1;
}
.section-header-content {
position: fixed;
bottom: 400px;
left: 200px;
color: white;
}
.main-title {
position: fixed;
bottom: 400px;
left: 200px;
color: white;
}
.section-header-content2 {
position: fixed;
bottom: 50px;
left: 200px;
color: white;
}
.main-title2 {
position: fixed;
bottom: 400px;
right: 200px;
color: white;
}
.section-video-bg {
margin-top: -10px;
}
.content {
padding: 40px 0 25 ;
}
.content h3 {
font-size: 27px;
line-height: 27px;
margin: 70px 0 30px 0;
}
.content .content-media {
width: 40%;
border-top: 1px solid #FFFFFF;
border-bottom: 1px solid #FFFFFF;
padding: 30px 0;
}
.content .content-media.right {
float: right;
margin-left: 20px;
}
.content .content-media.left {
float: right;
margin-right: 800px;
bottom: 600px;
}
.content .content-media img {
max-width: 100%;
}
.column {
float: left;
width: 50%;
}
.video-container {
position: relative;
bottom: 0%;
left: 0%;
height: 100%;
width: 100%;
overflow: hidden;
background: #000;
}
.video-container video {
position: relative;
z-index: 0;
top: 0;
bottom: 0;
}
.video-container video.fixed {
position: fixed;
top: 50px;
z-index: 0;
bottom: 0;
}
.video-container video.fillWidth {
width: 100%;
}
.wrapper {
margin: 0 auto;
width: 960px;
}
/* Responsive: Portrait tablets and up */
#media screen and (min-width: 768px) {
}
You have a lot of stray divs on your html as well as a lot of css properties not needed (e.g. float property) which are already done by bootstrap's default css.
Here is the correct way to nest your div columns within a row:
<section class="section">
<div class="container">
<div class="row">
<div class="col-xs-6">
<div class="content">
<div class="wrapper">
<img src="http://lorempixel.com/g/400/200/" class="img-responsive" alt=""/>
</div>
</div>
</div>
<div class="col-xs-6">
<p>Lorem Ipsum <em>Lorem</em>, Lorem impsum Lorem Ipsum Lorem Ipsum.</p>
</div>
</div>
</div>
</section>
Here is a jsfiddle with the above code: http://jsfiddle.net/AndrewL32/623ftfc2/
Your HTML is not properly formatted
<div class="row">
<div class="col-xs-10 col-sm-10 col-md-6">
<img class="img-responsive" src="http://lorempixel.com/g/400/200/">
</div>
<div class="col-xs-2 col-sm-2 col-md-6">
<p>Lorem Ipsum</p>
</div>
</div>
https://jsfiddle.net/j0m6ddpo/1/