Vertically align text on the right of the image
Your approaching it wrong, simply float the image to the left and update the margin to the right side instead
http://jsfiddle.net/rVTcv/140/
.how-right img {
float: left;
margin-right: 20px;
vertical-align :middle;
}
Left align text AND right align image in CSS
Hi i have a solution for you chek this link http://jsfiddle.net/8mQc4/15/.
It's based use some properties like:
float and vertical-align.
This code allows flexible height and width of img, and also his container center vertically de text.Just try with more large texts or images.
align images left and right automatically in css
for example with grid container and :nth-child(even) or :nth-child(odd)
.container {
display: grid;
}
img:nth-child(even) { justify-self: left;}
img:nth-child(odd) { justify-self: right; }
<div class="container">
<img src="https://picsum.photos/200/300" />
<img src="https://picsum.photos/200/300" />
<img src="https://picsum.photos/200/300" />
<img src="https://picsum.photos/200/300" />
<img src="https://picsum.photos/200/300" />
<img src="https://picsum.photos/200/300" />
<img src="https://picsum.photos/200/300" />
</div>
How can I center an image and place text under it to the left or right?
Is this the kind of thing you are thinking of?
I've just added display: flex
to the wrapper and then flex-direction: column
makes sure that they are stacked in a column (not a row).
You can then change text-align
property on the b
to whichever you'd like (left
, center
or right
).
p { display: flex; flex-direction: column; width: 600px; margin: auto;}
img { width: 600px; height: 150px;}
b { text-align: left;}
<p align="center"><img src="http://via.placeholder.com/600x150"> <b>text under it</b></p>
Have align image left, text center, image right on the same line
I think you need something like this one.
#container { width: 100%;}
#container > div { display: table-cell;}
#left { min-width: 150px; height: 150px;}
#middle { vertical-align: top; height: 150px;}
#right { min-width: 150px; height: 150px;}
<div id="container"> <div id="left"> <img style="width: 150px; height: 150px;" src="https://pbs.twimg.com/profile_images/378800000442759461/b483cdd049f470928e7b20051f95b8cc.jpeg"> </div> <div id="middle"> Today is September 12, 2015. It's a saturday partly cloudy </div> <div id="right"> <img style="width: 150px; height: 150px;" src="https://pbs.twimg.com/profile_images/378800000442759461/b483cdd049f470928e7b20051f95b8cc.jpeg"> </div> </div>
right align an image using CSS HTML
<img style="float: right;" alt="Sample Image" src="http://example.com/image.png" />
<div style="clear: right">
...text...
</div>
jsFiddle.
Align Images Left & Right using CSS
Something like this?
(or alternatively)
HTML
<body>
<div id="holder">
<div id="logo" class='left'>
<img src="http://images.google.com/intl/en_ALL/images/logos/images_logo_lg.gif" />
</div>
<div class='right'>
<img src="http://images.google.com/intl/en_ALL/images/logos/images_logo_lg.gif" />
</div>
<div style='clear:both;'></div>
<div id="wrapper"></div>
</div>
</body>
CSS
html, body {
height: 100%;
text-align:center;
margin: 0px;
padding: 0px;
background: #fff;
font-family:'Open Sans', sans-serif;
font-size: 11pt;
font-weight: 400;
color: #fff;
}
#holder {
margin :0 auto;
display:inline-block;
width: 850px;
}
.left {
float:left;
}
.right {
float:right;
}
#logo {
align:middle;
text-align:center
}
#wrapper {
height:200px;
position: relative;
padding: 0em 0em 0em 0em;
background: #fff;
border: 1px solid blue;
}
center one image, and right align another, in the same line
instead of float right, try
position: absolute; and right: 0;
and on .column :
position: relative;
Related Topics
How to Make Vertically Rotated Links in HTML
Using 'Box-Sizing: Border-Box' with 'Inline-Block' Elements
Why Do My Icons Line Up Top-To-Bottom Instead of Flowing Left-To-Right in a Div Layout
HTML 5 Autofocus Messes Up CSS Loading
Simple Two Column HTML Layout Without Using Tables
CSS - Internet Explorer and The <Main> Tag Background
How to Get CSS Pseudo Element: Checked to Work in Ie7 + Ie8
Overflow-X: Hidden Also Hides Vertical Content Too
Nested Rows in Bootstrap 3 Fail to Respect The Grid
@Font-Face Doesn't Work in Firefox (But Exact Same Code Works on Another Site)
How to Start New Row of CSS Table Cells Without a Row Wrapper Element
CSS - Placement of a Div in The Lower Left-Hand Corner
Change Navbar Color in Twitter Bootstrap 2.0.4
How to Use Tick/Checkmark Symbol (✓) Instead of Bullets in Unordered List