How do I make the both inline block div parallel? [duplicate] - html

This question already has answers here:
Align inline-block DIVs to top of container element
(5 answers)
Closed 2 years ago.
I trying to make a 2 parallel div in center to show the user info. Left div contain the user image and the name while the right div show the login details such as login name, position, department and etc. I been try set the line height same as my div height but the result is not what i want, or may be the line height doesn't fix the issue or i using the wrong way to achieve this. Beside this, I have try set the both div to inline-flex and make the 2 div float left. This can make the 2 div in parallel but not in the center of the page. Any better way to achieve this?
my code
<div style="text-align: center; width: 80%; margin: auto;">
<div
style="
display: inline-block;
width: 240px;
height: 270px;
text-align: center;
box-shadow: 0 .5px 5px 0 rgba(0,0,0,0.2);
"
>
<img
id="pf-img"
style="display: block; text-align: center; margin: 21px 45px 0px; border-radius: 50%; box-shadow: 0 .5px 5px 0 rgba(0,0,0,0.2);"
src="/assets/images/avatar_v3.png"
alt=""
width="150px"
/>
<div style="margin: 40px 0px;">
<span>Name</span>
</div>
</div>
<div style="display: inline-block; margin-left: 30px;">
<div style="display: block; box-shadow: 0 .5px 5px 0 rgba(0,0,0,0.2); padding: 10px;">
<div style="display: inline-block; width: 280px; text-align: left;">Login Name</div>
<div style="display: inline-block; width: auto;">Login Name</div>
</div>
<div style="display: block; box-shadow: 0 .5px 5px 0 rgba(0,0,0,0.2); padding: 10px; margin-top: 38px;">
<div style="display: inline-block; width: 280px; text-align: left;">Login Name</div>
<div style="display: inline-block; width: auto;">Login Name</div>
</div>
<div style="box-shadow: 0 .5px 5px 0 rgba(0,0,0,0.2); padding: 10px; margin-top: 38px;">
<div style="display: inline-block; width: 280px; text-align: left;">Login Name</div>
<div style="display: inline-block; width: auto;">Login Name</div>
</div>
<div style="box-shadow: 0 .5px 5px 0 rgba(0,0,0,0.2); padding: 10px; margin-top: 38px;">
<div style="display: inline-block; width: 280px; text-align: left;">Login Name</div>
<div style="display: inline-block; width: auto;">Login Name</div>
</div>
</div>
</div>
My result:
my result image

I am not sure why you are bringing up flex when you are not using such CSS feature.
Adding the CSS property vertical-align: top; to left column should do the trick.
<div style="text-align: center; width: 80%; margin: auto;">
<div
style="
display: inline-block;
width: 240px;
height: 270px;
text-align: center;
vertical-align: top;
box-shadow: 0 .5px 5px 0 rgba(0,0,0,0.2);
"
>
<img
id="pf-img"
style="display: block; text-align: center; margin: 21px 45px 0px; border-radius: 50%; box-shadow: 0 .5px 5px 0 rgba(0,0,0,0.2);"
src="/assets/images/avatar_v3.png"
alt=""
width="150px"
/>
<div style="margin: 40px 0px;">
<span>Name</span>
</div>
</div>
<div style="display: inline-block; margin-left: 30px;">
<div style="display: block; box-shadow: 0 .5px 5px 0 rgba(0,0,0,0.2); padding: 10px;">
<div style="display: inline-block; width: 280px; text-align: left;">Login Name</div>
<div style="display: inline-block; width: auto;">Login Name</div>
</div>
<div style="display: block; box-shadow: 0 .5px 5px 0 rgba(0,0,0,0.2); padding: 10px; margin-top: 38px;">
<div style="display: inline-block; width: 280px; text-align: left;">Login Name</div>
<div style="display: inline-block; width: auto;">Login Name</div>
</div>
<div style="box-shadow: 0 .5px 5px 0 rgba(0,0,0,0.2); padding: 10px; margin-top: 38px;">
<div style="display: inline-block; width: 280px; text-align: left;">Login Name</div>
<div style="display: inline-block; width: auto;">Login Name</div>
</div>
<div style="box-shadow: 0 .5px 5px 0 rgba(0,0,0,0.2); padding: 10px; margin-top: 38px;">
<div style="display: inline-block; width: 280px; text-align: left;">Login Name</div>
<div style="display: inline-block; width: auto;">Login Name</div>
</div>
</div>
</div>

Okay, before that I have some tips:
1 ° Avoid in-line styling
This makes the HTML code confusing, difficult to read
2 ° Use CSS classes
Classes allow you to apply the same style to several elements at the same time
3 ° Use correct marking
Divs are generic containers for other elements. They serve to group and separate elements of the page. You have only used divs to structure the entire page, not taking advantage of the semantic meaning of other elements of HTML.
Having made these observations, the solution I propose is as follows:
<!DOCTYPE html>
<html>
<head>
<style>
.user-info-container {
display:flex;
}
.user-img {
margin-right: 1rem;
}
.user-img img {
width: 100%;
height: auto;
}
.user-info-badge {
display:flex;
align-items:center;
box-shadow: 0 .5px 5px 0 rgba(0,0,0,0.2);
padding: 0.5rem 1rem;
margin-bottom: 1rem;
}
.user-info-badge:last-child {
margin-bottom: 0;
}
.user-info-badge h3 {
width: 150px;
text-align:left;
}
</style>
</head>
<body>
<div class="user-info-container">
<div class="user-img">
<img src="/assets/images/avatar_v3.png">
</div>
<div class="user-info-badges">
<div class="user-info-badge">
<h3>Username</h3>
<span>teste183</span>
</div>
<div class="user-info-badge">
<h3>Email</h3>
<span>teste.teste#teste.com</span>
</div>
<div class="user-info-badge">
<h3>Nascimento</h3>
<span>05-02-2020</span>
</div>
</div>
</div>
</body>
</html>

Related

How do I prevent 3 overlapping images in HTML, CSS?

I am trying to create 3 cards that stand at the bottom of the webpage but the 3 cards are overlapping. Can you help me find my mistake please? :)
.card {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.144);
transition: 0.3s;
border-radius: 13px;
width: 320px;
height: 455px;
cursor: pointer;
position: absolute;
margin-left: 4%;
bottom: 10px;
margin-right: 4%;
}
.card:hover {
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.397);
}
.container {
padding: 2px 16px;
font-family: 'Rubik', sans-serif;
cursor: pointer;
}
.row {
display: flex;
}
.row::after {
content: "";
clear: both;
display: table;
}
<div class="row">
<div class="card">
<img src="resources/images/Front1.png" style="width: 100%;" height="320px">
<div class="container">
<h3><b>Create checklists</b></h3>
<p>Make your own customizable checklist to remain happy and healthy</p>
</div>
</div>
<div class="card">
<img src="resources/images/Front2.jpeg" style="width: 100%;">
<div class="container">
<h3><b>Take notes</b></h3>
<p>Write your own notes with fun, colourful tools</p>
</div>
</div>
<div class="card">
<img src="resources/images/Front3.jpeg" style="width: 100%;" height="320px">
<div class="container">
<h3><b>Create calendars</b></h3>
<p>Add pictures to your calendars and customize according to your preferences</p>
</div>
</div>
</div>
The problem was caused by the position: absolute; style in your CSS. Basically, you set all 3 cards to the same position which is why they overlapped.
I also changed your card's height to min-height. This is because the text was flowing out of the card and min-height would prevent this.
.card {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.144);
transition: 0.3s;
border-radius: 13px;
width: 320px;
min-height: 455px;
cursor: pointer;
margin-left: 4%;
margin-right: 4%;
}
.card:hover {
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.397);
}
.container {
padding: 2px 16px;
font-family: 'Rubik', sans-serif;
cursor: pointer;
}
.row {
display: flex;
}
.row::after {
content: "";
clear: both;
display: table;
}
<div class="row">
<div class="card">
<img src="resources/images/Front1.png" style="width: 100%;" height="320px">
<div class="container">
<h3><b>Create checklists</b></h3>
<p>Make your own customizable checklist to remain happy and healthy</p>
</div>
</div>
<div class="card">
<img src="resources/images/Front2.jpeg" style="width: 100%;">
<div class="container">
<h3><b>Take notes</b></h3>
<p>Write your own notes with fun, colourful tools</p>
</div>
</div>
<div class="card">
<img src="resources/images/Front3.jpeg" style="width: 100%;" height="320px">
<div class="container">
<h3><b>Create calendars</b></h3>
<p>Add pictures to your calendars and customize according to your preferences</p>
</div>
</div>
</div>
remove "position: absolute" and things would work fine. Or if you're trying to display somethign else?

HTML - change image inside frame and keep frame size intact

My main goal is to have a simple frame (as you can see) with few text lines and images. The thing I want to do, is make this frame flexible. By that I mean - if I change picture inside of it (bigger -> smaller) the frame should change. It should stay fixed.
Online editor: https://www.bootply.com/Y09Zn1wir3#
HTML:
<div class="col-md-4">
<div class="single-image-wrap">
<div class="single-image">
<div class="name">NAME</div>
<div class="img-wrap">
<img src="https://cdn.pixabay.com/photo/2013/07/12/14/07/basketball-147794_960_720.png" class="first-image">
</div>
<div class="extra-info">
<div class="bottom-text">ABC</div>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="single-image-wrap">
<div class="single-image">
<div class="name">NAME</div>
<div class="img-wrap">
<img src="https://cdn.pixabay.com/photo/2013/07/12/14/07/basketball-147794_960_720.png" class="second-image">
</div>
<div class="extra-info">
<div class="bottom-text">ABC</div>
</div>
</div>
</div>
</div>
CSS:
/* CSS used here will be applied after bootstrap.css */
.single-image{
border: 1px solid orange;
width: 100%;
text-align: center;
margin: 0px 0px 15px 0px;
float: right;
}
.name{
padding: 20px 0px 0px 0px;
color: black;
height: 75px;
font-size: 18px;
}
.img-wrap{
padding-bottom: 50px;
padding-top: 25px;
}
.first-image{
width: 200px;
}
.second-image{
width: 150px;
}
.extra-info{
border-top: 1px solid orange;
}
.bottom-text{
padding-top: 15px;
height: 50px;
letter-spacing: 0.1em;
}
I tried to add height property to such as:
.single-image{
...
height: 405px;
}
Result: https://www.codeply.com/go/2s2hH3nbju
But it doesn't look correct, as bottom text floats somewhere up.
I need a solution for different type of image sizes. Any ideas?
You need to set the height of .img-wrap, too.
.single-image{
border: 1px solid orange;
width: 100%;
text-align: center;
margin: 0px 0px 15px 0px;
float: right;
height: 405px;
}
.img-wrap{
padding-bottom: 50px;
padding-top: 25px;
height:250px;
overflow:hidden;
}
Try to add this new line in your css code.
.img-wrap{
min-height: 275px;
}
it will looks like this
Output
Try using flex
.single-image{
border: 1px solid orange;
width: 100%;
text-align: center;
display: flex;
flex-direction: column;
height: 100%;
justify-content: space-between;
}
.name{
padding: 20px 0px 0px 0px;
color: black;
height: 75px;
font-size: 18px;
}
.img-wrap{
padding-bottom: 50px;
padding-top: 25px;
}
.first-image{
width: 200px;
}
.second-image{
width: 150px;
}
.extra-info{
border-top: 1px solid orange;
align-self: bottom;
}
.bottom-text{
padding-top: 15px;
height: 50px;
letter-spacing: 0.1em;
}
.images-wrap{
display: flex;
}
.single-image-wrap {
height: 100%;
margin-bottom: 15px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="row images-wrap">
<div class="col-xs-6 col-md-4">
<div class="single-image-wrap">
<div class="single-image">
<div class="name">NAME</div>
<div class="img-wrap">
<img src="https://cdn.pixabay.com/photo/2013/07/12/14/07/basketball-147794_960_720.png" class="first-image">
</div>
<div class="extra-info">
<div class="bottom-text">ABC</div>
</div>
</div>
</div>
</div>
<div class="col-xs-6 col-md-4">
<div class="single-image-wrap">
<div class="single-image">
<div class="name">NAME</div>
<div class="img-wrap">
<img src="https://cdn.pixabay.com/photo/2013/07/12/14/07/basketball-147794_960_720.png" class="second-image">
</div>
<div class="extra-info">
<div class="bottom-text">ABC</div>
</div>
</div>
</div>
</div>
</div>

How to keep all divs in a row the same height [duplicate]

This question already has answers here:
How can I make Bootstrap columns all the same height?
(34 answers)
Closed 5 years ago.
I'm working on a page that uses Bootstrap and have used this to define columns on this Codepen pen: https://codepen.io/smifaye/pen/GmeQrV
However one thing I can't seem to figure out is how to keep the height of the boxes uniform. I've set a min-height value for these boxes but my mind has gone blank as to how to make all divs resize at once.
.recycling {
background-color: white;
border: 1px solid #CCCCCC;
padding: 0;
min-height: 250px;
}
Also I'd like the buttons to stay at the bottom of the div but can't figure this out either :(
Any help would be massively appreciated.
(The menu area on the right is part of the design of the website and can't be changed)
Used Flexbox you can set equal height in div
.row-eq-height {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
.recycling {
background-color: white;
border: 1px solid #CCCCCC;
padding: 0;
//min-height: 250px;
height: 100%;
}
.button {
min-height: 36px;
height: auto;
width: auto;
padding: 0 36px 0 36px;
border: 2px solid #00019F;
font-size: 1em;
color: #FFFFFF;
background-color: #00019F;
border-radius: 5px;
text-decoration: none;
}
.button:hover {
background-color: #2D389C;
cursor: pointer;
}
.button:focus {
border: 2px solid #FF9900;
outline: 0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row " style="margin: 0px;">
<div class="col-md-4">
Menu area that can't be removed
</div>
<div class="col-md-8">
<div class="row row-eq-height">
<div class="col-sm-6 col-md-4">
<div class="recycling">
<h3 style="color: white; padding: 10px; margin: 0px; background-color: #00019f;">Your property</h3>
<p style="padding: 10px 10px 0px;"><strong>Find</strong> your collection days</p>
<p style="padding: 0px 10px;"><strong>Report</strong> a missed collection</p>
<p style="padding: 0px 10px;"><strong>Order</strong> a new recycling bin, box or bag</p>
<div style="padding: 0px 10px 10px; text-align: center;">
<form action="https://environmentservices.camden.gov.uk/property"> <button class="button">Find, report, order</button> </form>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4">
<div class=" recycling">
<h3 style="color: white; padding: 10px; margin: 0px; background-color: #00019f;">Cleansing issues</h3>
<p style="padding: 10px 10px 0px;"><strong>Report</strong></p>
<ul>
<li>Dumped rubbish</li>
<li>Dog fouling</li>
<li>Graffiti</li>
<li>Other</li>
</ul>
<div style="padding: 0px 10px 10px; text-align: center;">
<form action="https://environmentservices.camden.gov.uk/street"> <button class="button">Report</button> </form>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4">
<div class="recycling">
<h3 style="color: white; padding: 10px; margin: 0px; background-color: #00019f;">Additional information</h3>
<ul style="padding-top: 10px;">
<li>Frequently asked questions</li>
<li>Communal collections</li>
<li>Large household item collections</li>
<li>More</li>
</ul>
<div style="padding: 0px 10px 10px; text-align: center;">
<form action="http://www.camden.gov.uk/ccm/content/environment/waste-and-recycling/recycling-rubbish-and-reuse/"> <button class="button">View</button> </form>
</div>
</div>
</div> </div>
</div>
you can use display:flex on col-md-8 to equal the heights of the col-md-4 then add height:100% to recycling plus some padding-bottom to make 'room' for the buttons
then add position:absolute and position the form at the bottom of every recycling box
P.S. your HTML is a mess. inline styles, col-12 inside col-8 . columns inside columns without any rows that's not correct . see here > http://getbootstrap.com/examples/grid/ . columns should be nested inside ROW's and then inside other columns eg
<div class="col-md-8">
.col-md-8
<div class="row">
<div class="col-md-6">.col-md-6</div>
<div class="col-md-6">.col-md-6</div>
</div>
</div>
for your solution see snippet below or jsFiddle
.col-md-8 {
display: flex;
}
.recycling {
background-color: white;
border: 1px solid #CCCCCC;
padding: 0 0 60px;
height: 100%;
position: relative;
}
.button {
min-height: 36px;
height: auto;
width: auto;
padding: 0 36px 0 36px;
border: 2px solid #00019F;
font-size: 1em;
color: #FFFFFF;
background-color: #00019F;
border-radius: 5px;
text-decoration: none;
}
.button:hover {
background-color: #2D389C;
cursor: pointer;
}
form {
position: absolute;
left: 0;
right: 0;
margin: 0 auto;
bottom: 15px;
text-align: center;
}
.button:focus {
border: 2px solid #FF9900;
outline: 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<div class="row" style="margin: 0px;">
<div class="col-md-4">
Menu area that can't be removed
</div>
<div class="col-md-8">
<div class="col-sm-6 col-md-4">
<div class="col-md-12 recycling">
<h3 style="color: white; padding: 10px; margin: 0px; background-color: #00019f;">Your property</h3>
<p style="padding: 10px 10px 0px;"><strong>Find</strong> your collection days</p>
<p style="padding: 0px 10px;"><strong>Report</strong> a missed collection</p>
<p style="padding: 0px 10px;"><strong>Order</strong> a new recycling bin, box or bag</p>
<div style="padding: 0px 10px 10px; text-align: center;">
<form action="https://environmentservices.camden.gov.uk/property">
<button class="button">Find, report, order</button>
</form>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4">
<div class="col-md-12 recycling">
<h3 style="color: white; padding: 10px; margin: 0px; background-color: #00019f;">Cleansing issues</h3>
<p style="padding: 10px 10px 0px;"><strong>Report</strong></p>
<ul>
<li>Dumped rubbish</li>
<li>Dog fouling</li>
<li>Graffiti</li>
<li>Other</li>
</ul>
<div style="padding: 0px 10px 10px; text-align: center;">
<form action="https://environmentservices.camden.gov.uk/street">
<button class="button">Report</button>
</form>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4">
<div class="col-md-12 recycling">
<h3 style="color: white; padding: 10px; margin: 0px; background-color: #00019f;">Additional information</h3>
<ul style="padding-top: 10px;">
<li>Frequently asked questions</li>
<li>Communal collections</li>
<li>Large household item collections</li>
<li>More</li>
</ul>
<div style="padding: 0px 10px 10px; text-align: center;">
<form action="http://www.camden.gov.uk/ccm/content/environment/waste-and-recycling/recycling-rubbish-and-reuse/">
<button class="button">View</button>
</form>
</div>
</div>
</div>
</div>
If you do not want:
Javascript
CSS3
Then you can use this:
.table {
display: table;
width: 100%;
border-spacing: 10px 0;
}
.cell {
position: relative;
display: table-cell;
border: 1px solid #f00;
padding: 15px 15px 40px;
}
button {
position: absolute;
bottom: 15px;
right: 15px;
}
<div class="table">
<div class="cell">
<div class="inner">
<strong>Title</strong>
<p>Some text.</p>
<button>Button</button>
</div>
</div>
<div class="cell">
<div class="inner">
<strong>Title</strong>
<p>Some text.</p>
<button>Button</button>
</div>
</div>
<div class="cell">
<div class="inner">
<strong>Title</strong>
<p>Some text.</p>
<p>Some text.</p>
<p>Some text.</p>
<button>Button</button>
</div>
</div>
</div>
Of course, you can target the table and cell class with media queries to disable it for phones for example.
If you cannot use JS/jQuery, then you should set both min-height and max-height for these div's.
e.g.
.recycling {
background-color: white;
border: 1px solid #CCCCCC;
padding: 0;
min-height: 250px;
max-height: 250px;
}

How to move second image to center of div [responsive design]?

How to move second image to center of div [responsive design] ?
https://jsfiddle.net/ydufL6o2/
I have 3 image,
first image position is left. It's ok.
third image position is right. It's ok.
But i have issue on second image, how can i move second image to center [responsive design] ?
<div style="position: relative;width: 100%;height: 40px;text-align: center;background-color: #373737;padding: 10px 0px;">
<div style=" display: block; position: relative; margin: 4px 0px; float: left; margin-left: 1.5%;">
<img src="https://thumb-cc.s3.envato.com/files/189105725/KMRS%20Thumbnail.jpg" style="/* margin: 16px auto; */height: 31px;border: none;width: 31px;" height="31px" width="111px">
</div>
<div style=" display: block; position: relative; margin: 4px auto; float: left; ">
<img src="https://thumb-cc.s3.envato.com/files/189105725/KMRS%20Thumbnail.jpg" style="width: 31px;height: 31px;border: none;" height="31px" width="111px">
</div>
<div style=" display: block; position: relative; margin: 4px 10px; float: right; margin-right: 1.5%; ">
<img src="https://thumb-cc.s3.envato.com/files/189105725/KMRS%20Thumbnail.jpg" style="/* margin: 16px auto; */height: 31px;border: none;width: 31px;" height="31px" width="111px">
</div>
</div>
If you want to make element centered you can use margin: 0 auto, however - since your element is blocked it will take 100% of the width.
You can change that element to be inline-block and then use the margin: 0 auto to do the trick.
<div style="position: relative;width: 100%;height: 40px;text-align: center;background-color: #373737;padding: 10px 0px;">
<div style=" display: block; position: relative; margin: 4px 0px; float: left; margin-left: 1.5%;">
<img src="https://thumb-cc.s3.envato.com/files/189105725/KMRS%20Thumbnail.jpg" style="/* margin: 16px auto; */height: 31px;border: none;width: 31px;" height="31px" width="111px">
</div>
<div style=" display: inline-block; position: relative; margin: 4px auto; ">
<img src="https://thumb-cc.s3.envato.com/files/189105725/KMRS%20Thumbnail.jpg" style="width: 31px;height: 31px;border: none;" height="31px" width="111px">
</div>
<div style=" display: block; position: relative; margin: 4px 10px; float: right; margin-right: 1.5%; ">
<img src="https://thumb-cc.s3.envato.com/files/189105725/KMRS%20Thumbnail.jpg" style="/* margin: 16px auto; */height: 31px;border: none;width: 31px;" height="31px" width="111px">
</div>
</div>
Regarding the comment about the 100%-width input in the center - check this fiddle:
https://jsfiddle.net/62b6prwo/
Remove the: float:left;
from the division and adjust the margin and padding to get the desired output.
You can do it like this :
<div style="position: relative;width: 100%;height: 40px;text-align: center;background-color: #373737;padding: 10px 0px;">
<div style="
display: block;
position: relative;
margin: 4px 0px;
float: left;
margin-left: 1.5%;
">
<img src="https://thumb-cc.s3.envato.com/files/189105725/KMRS%20Thumbnail.jpg" style="/* margin: 16px auto; */height: 31px;border: none;width: 31px;" height="31px" width="111px">
</div>
<div style="
display: block;
position: absolute;
left: 0;
right: 0;
margin: 4px 0 4px ;
">
<img src="https://thumb-cc.s3.envato.com/files/189105725/KMRS%20Thumbnail.jpg" style="width: 31px;height: 31px;border: none;" height="31px" width="111px">
</div>
<div style="
display: block;
position: relative;
margin: 4px 10px;
float: right;
margin-right: 1.5%;
">
<img src="https://thumb-cc.s3.envato.com/files/189105725/KMRS%20Thumbnail.jpg" style="/* margin: 16px auto; */height: 31px;border: none;width: 31px;" height="31px" width="111px">
</div>
</div>
It sets the middle div to absolute, allowing you to move it to the center of the wrapper, by using left: 0; and right: 0;
This works, play around with the margin settings so you can position the third image without using negative top margin.
<div style="position: relative;width: 100%;height: 40px;text-align: center;background-color: #373737;padding: 10px 0px;">
<div style=" display: block; position: relative; margin: 4px 0px; float: left; margin-left: 1.5%;">
<img src="https://thumb-cc.s3.envato.com/files/189105725/KMRS%20Thumbnail.jpg" style="/* margin: 16px auto; */height: 31px;border: none;width: 31px;" height="31px" width="111px">
</div>
<div style=" display: block; position: relative; margin: 4px auto; text-align: center; ">
<img src="https://thumb-cc.s3.envato.com/files/189105725/KMRS%20Thumbnail.jpg" style="width: 31px;height: 31px;border: none;" height="31px" width="111px">
</div>
<div style=" display: block; position: absolute; right: 10px; margin-top: -35px; margin-right: 1.5%; ">
<img src="https://thumb-cc.s3.envato.com/files/189105725/KMRS%20Thumbnail.jpg" style="/* margin: 16px auto; */height: 31px;border: none;width: 31px;" height="31px" width="111px">
</div>
</div>
Remove the float:left; on the middle div, and change the margin to margin:auto;.
Change the display on the divs from display:block; to display:inline; so they remain next to one another.
Change the middle image to position:relative; and add top:4px; to position vertically.
<div style="position: relative;width: 100%;height: 40px;text-align: center;background-color: #373737;padding: 10px 0px;">
<div style="
display: inline;
position: relative;
margin: 4px 0px;
float: left;
margin-left: 1.5%;
">
<img src="https://thumb-cc.s3.envato.com/files/189105725/KMRS%20Thumbnail.jpg" style="/* margin: 16px auto; */height: 31px;border: none;width: 31px;" height="31px" width="111px">
</div>
<div style="
display: inline;
position: relative;
margin:auto;
">
<img src="https://thumb-cc.s3.envato.com/files/189105725/KMRS%20Thumbnail.jpg" style="width: 31px;height: 31px;border: none; position:relative; top:4px;" height="31px" width="111px">
</div>
<div style="
display: inline;
position: relative;
margin: 4px 10px;
float: right;
margin-right: 1.5%;
">
<img src="https://thumb-cc.s3.envato.com/files/189105725/KMRS%20Thumbnail.jpg" style="/* margin: 16px auto; */height: 31px;border: none;width: 31px;" height="31px" width="111px">
</div>
</div>
Please see:
https://jsfiddle.net/ydufL6o2/4/
NOTE
Inline styling is NOT the way to style elements. It should be done in the stylesheet or in the style tags in the head part of the HTML. Here is the proper code.
Basically I cleaned up your code A LOT by adding IDs and classes.
What you had to do is remove the float: left property from the middle div.
After that, you have to change the display: block; to display: inline-block, as I did in the childDiv class divs.
That solves the problem, as shown in this snippet.
#parentDiv {
position: relative;
width: 100%;
height: 40px;
text-align: center;
background-color: #373737;
padding: 10px 0px;
}
.childDiv {
display: inline-block;
position: relative;
margin: 4px 0px;
}
img {
height: 31px;
border: none;
width: 31px;
}
<div id="parentDiv">
<div class="childDiv" style="float: left; margin-left: 1.5%;">
<img src="https://thumb-cc.s3.envato.com/files/189105725/KMRS%20Thumbnail.jpg">
</div>
<div class="childDiv">
<img src="https://thumb-cc.s3.envato.com/files/189105725/KMRS%20Thumbnail.jpg">
</div>
<div class="childDiv" style="float: right; margin-right: 1.5%;">
<img src="https://thumb-cc.s3.envato.com/files/189105725/KMRS%20Thumbnail.jpg">
</div>
</div>

html bootstrap display paragraph beside image

The image is basically exactly what I want. However, I need the text paragraph to be aligned with the top of the image. There must be an easy way to get it to move up. I have no idea what it is though? Thanks!
#homePost {
width:50%;
height:auto;
box-shadow: 0 0 0 6px #fff, 0 0 0 12px #888;
margin-right: 25px;
margin-bottom: 20px;
}
<div class="well well-sm" style="border: 2px solid chartreuse; background: white;">
<div class="row">
<div class="col-sm-12">
<p><h4>Toronto Maple Leafs Sucking again this year.</h4></p>
<p>Date Posted: 24th of June, 2016</p>
<p style="padding-top: 5px;"> </p>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<p style="padding-left: 20px; padding-right: 20px;">
<img style="float:left" src="http://i.stack.imgur.com/E0kmH.png" id="homePost">
<span style="float:right">
<p>TEXT GOES IN HERE </p>
</span>
</p>
</div>
</div>
</div>
add margin-top: 20px;
Like this:
#homePost {
width: 50%;
height: auto;
box-shadow: 0 0 0 6px #fff, 0 0 0 12px #888;
margin-right: 25px;
margin-bottom: 20px;
margin-top: 20px;
}
See This Image
add a class to the text like align-top then use vertical-align: text-top; which will look like this .align-top {
vertical-align: text-top;
}