My vertical align of image doesnt work - html

Im trying to vertically align three images inside a div. But somehow my vertical alignment doesn't work and I cannot undertand what I'm doing wrong.
My html:
<div class="maketable">
<div class="makecell" id="cell1">
<input type="checkbox" id="nutrbox" value="nutrition" onclick="updateChoice()" />
<label for="nutrbox" onclick="updateChoice()">Jag vill ha näringstabell i slutet av min bok</label>
</div>
<div class="makecell" id="cell2">
<div class="arrowdiv">
<img src="./images/leftarrow.png" width="64px" />
</div>
<div id="imagediv">
<img src="./images/pages/part3/nutrition/Nutrition_Front-1.png" width="296px" />
</div>
<div class="arrowdiv">
<img src="./images/rightarrow.png" width="64px" />
</div>
</div>
</div>
And my css:
.maketable{
margin-left: auto;
margin-right: auto;
width: 100%;
margin-bottom: 20px;
display: table;
clear: both;
}
.makecell{
vertical-align: middle;
display: table-cell;
}
#imagediv{
display: inline-block;
margin: 30px auto 0px auto;
width: 296px;
height: 420px;
color: #000;
border: 1px solid black;
text-align: center;
}
.arrowdiv {
display: inline-block;
width: 64px;
margin: 3px;
}
The result is the following:
As you can see, I want to have the arrows vertically aligned in the middle of the center picture, but how ever I do it, i cannot get it to work. I've tried fiddling with float but that made it much worse. Can anyone spot what i'm doing wrong?

You need to apply display: inline-block (or table-cell) and vertical-align: middle to .makecell, #imagediv and .arrowdiv.
Fiddle
.maketable {
margin-left: auto;
margin-right: auto;
width: 100%;
margin-bottom: 20px;
display: table;
clear: both;
}
.makecell, #imagediv, .arrowdiv {
vertical-align: middle;
display: inline-block;
}
#imagediv {
margin: 30px auto 0px auto;
width: 296px;
height: 420px;
color: #000;
border: 1px solid black;
text-align: center;
}
.arrowdiv {
width: 64px;
margin: 3px;
}
<div class="maketable">
<div class="makecell" id="cell1">
<input type="checkbox" id="nutrbox" value="nutrition" onclick="updateChoice()" />
<label for="nutrbox" onclick="updateChoice()">Jag vill ha näringstabell i slutet av min bok</label>
</div>
<div class="makecell" id="cell2">
<div class="arrowdiv">
<img src="http://www.dummyimage.com/64" width="64px" />
</div>
<div id="imagediv">
<img src="http://www.dummyimage.com/296x420" width="296px" />
</div>
<div class="arrowdiv">
<img src="http://www.dummyimage.com/64" width="64px" />
</div>
</div>
</div>

Just change the display: inline-block; to display: table-cell; and add vertical-align: middle; in your .arrowdiv and #imagediv CSS:
#imagediv{
display: table-cell;
margin: 30px auto 0px auto;
width: 296px;
height: 420px;
color: #000;
border: 1px solid black;
text-align: center;
vertical-align: middle;
}
.arrowdiv {
display: table-cell;
width: 64px;
margin: 3px;
vertical-align: middle;
}
Here is a DEMO Fiddle.

Related

Style CSS for logo and text on same line

I am trying to achieve following and I cannot get it to do what I want.
90% of the page and centered
5px underline
logo on the left
text on the right but bottom right justified
.box2 {
border-bottom: 5px solid #2ea9e0;
overflow: hidden;
max-width: 90%;
}
.alignleft {
float: left;
}
.alignright {
float: right;
vertical-align: bottom;
overflow: hidden;
}
img {
width: 115px;
height: 91px;
}
<div class="box2">
<p class="alignleft"><img src="http://placehold.it/115x91" alt=""></p>
<p class="alignright">Hello</p>
</div>
<div style="clear: both"></div>
What I want to do
What I am getting
You can do it with the Flexbox:
.box2 {
display: flex; /* displays flex-items (children) inline */
align-items: flex-end; /* vertically aligns them at the bottom */
justify-content: space-between; /* places them away from each other as far as it can */
border-bottom: 5px solid #2ea9e0;
overflow: hidden;
max-width: 90%;
margin: 0 auto;
}
img {
width: 115px;
height: 91px;
}
<div class="box2">
<p class="alignleft"><img src="http://placehold.it/115x91" alt=""></p>
<p class="alignright">Hello</p>
</div>
flex will help you to achieve this. Added some css in .box2. Here align-items: baseline; with flex will solve your problem.
.box2{
align: center;
border-bottom: 5px solid #2ea9e0;
overflow: hidden;
max-width: 90%;
display: flex;
justify-content: space-between;
align-items: baseline;
}
.alignleft {
float: left;
}
.alignright {
float: right;
vertical-align: bottom;
overflow:hidden;
}
<div class="box2">
<p class="alignleft"><img src="http://via.placeholder.com/140x100" alt="" width="115" height="91" /></p>
<p class="alignright">Hello</p>
</div>
<div style="clear: both;"></div>
Use flex property. With it there is no need for float property.
.box2{
display: flex;
align-items: flex-end;
margin: 0 auto;
border-bottom: 5px solid #2ea9e0;
overflow: hidden;
max-width: 90%;
}
.alignright {
margin-left: auto;
margin-bottom: 0;
padding: 0;
}
p {
padding: 0;
margin-bottom: 0;
}
<div class="box2">
<p class="alignleft"><img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxAQEBAPDxIPDQ8PDg8QDQ8PDw8PDw0PFRcWFhURFRUYHSggGB0lGxUVITEhJSktLi4uFx8zODMsNyguLjcBCgoKDg0OGBAQGi0eHR0tKy0tKzctKy4rLS0vLS0tLy0rLSsrLSsrLSs1LSstLS0tLS0rLisrLS0tLTctLS0tK//AABEIAKMBNgMBIgACEQEDEQH/xAAcAAEAAQUBAQAAAAAAAAAAAAAABwMEBQYIAQL/xABEEAABAwICBgUJBAkDBQAAAAABAAIDBBEFIQYHEjFBURMyYXGxCBQiNXJ0gZGyJUJSoSNDYoKSs8HE0TOi0hVTk9Ph/8QAGgEBAAMBAQEAAAAAAAAAAAAAAAECAwQFBv/EACcRAQACAgECBQQDAAAAAAAAAAABAgMRMSFBBBIyUWETFCKxQpHR/9oADAMBAAIRAxEAPwCcUREBERAREQEREBck60/XOI+8n6WrrZck60/XOI+8n6WoNVREUJEREBERARFk8P0dragB0FLUysdukbDJ0due3bZA7boMYi2UaA4nxp2t9qppW/kXr4l0HxBv6ph7qmm/5oNdRZOp0erI+tBJbiWDpQO8svZY1zSCQQQRvBFiPgg8REQEREBERAU3eTPvxTuof7hQipu8mffindQ/3CCckRFKBERAREQEREBERAREQEREBERAREQFyTrT9c4j7yfpautlyVrS9c4j7yfpaolMNURfVl5ZNjxF7ZZXRzR6oxCYQUzQSBtSSPJbFAzi+R3AfmTkASgxkELpHNYxrpHuIaxjGlz3k7gAMyVI2jmqiZ4EmIyeaMOfm8Wy+pcM+serHw37R5gKQNFtF6XDGfoB0tQW2lq3tAlfzawfq2dgzPElZOSRBi8L0eoKK3m1NE14z6aQdNPe1rh777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t9melPZTZVSyWTYp7K82VVsvLJs0p7Klnyfh6eJexQ+NQoqIUsagh6eI+zReNQtcM/lCl/TKYERF2ucREQEREBERAREQEREBERAREQEREHi5q1getK73h3gF6i5/EemGuLlry9RFyNxERAXi9RAXi9RB4vURB4i9RAXi9RAXgXqICIiDxSvqD6+I+zR+M69RaYfXCmT0yl5ERd7mEREBERAREQEREH//Z" alt="" width="115" height="91" /></p>
<p class="alignright">Hello</p>
</div>
.box2{
align: center;
border-bottom: 5px solid #2ea9e0;
overflow: hidden;
max-width: 100%;
}
.alignleft {
float: left;
}
.alignright {
float: right;
vertical-align: bottom;
margin-top:90px;
}
<div class="box2">
<p class="alignleft">
<img src="https://www.w3schools.com/howto/img_avatar.png" alt="" width="115" height="91" />
</p>
<p class="alignright">HELLO</p>
</div>
.box2{
align: center;
border-bottom: 5px solid #2ea9e0;
overflow: hidden;
max-width: 90%;
margin-left:15px
}
.alignleft {
float: left;
}
.alignright {
float: Right;
vertical-align: bottom;
overflow:hidden;
padding: 0px 0px 0px 10px;
}
<div class="box2">
<p class="alignleft"><img src="logo.jpg" alt="" width="115" height="91" /></p>
<p class="alignright">Hello</p>
</div>

How does one vertically center an Image inside parent div that's using css display:table? [duplicate]

This question already has answers here:
How do I vertically center text with CSS? [duplicate]
(37 answers)
Closed 5 years ago.
I want to try and have the div that contains the image on the left to be centered vertically. I have tried numerous things but I keep running into issues.
weekly-middle is the container div to the div which is left which contains the image that I want centered.
The text is already centered.
.weekly-middle {
text-align: center;
width: 100%;
/* height:100%;*/
border: none;
border-collapse: collapse;
margin: 0px;
padding-top: 56px;
padding-bottom: 56px;
content: "";
display: table;
/*clear: both;*/
}
.left {
text-align: left;
padding: 20px;
width: 100px;
float: left;
/* padding-top: 56px;
padding-bottom: 56px;*/
vertical-align: middle;
height: 300px
}
.right {
margin-left: 100px;
float: left;
padding-top: 56px;
padding-bottom: 56px;
}
<div class="weekly-middle teal">
<div class="left">
<img width="50" height="50" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f9/Wiktionary_small.svg/350px-Wiktionary_small.svg.png" />
</div>
<div class="right">
<h1>Some Title</h1>
<p class="title">Problems Solved</p>
</div>
</div>
Solution provided in comment below
Refer to Joseph Marikle comment with link to JSFiddle.
Use flexbox. It's a very powerfull CSS tool :
.left {
text-align: left;
padding: 20px;
width: 100px;
float: left;
/* padding-top: 56px;
padding-bottom: 56px;*/
vertical-align: middle;
height: 300px;
display:flex;
flex-direction:column;
justify-content:center;
}
you can try following code
<div class="left">
<div class="display-table">
<div class="display-table-cell">
<img width="50" height="50" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f9/Wiktionary_small.svg/350px-Wiktionary_small.svg.png" />
</div>
</div>
and for the css you can write:
.display-table{
display: table;
width:100%;
}
.display-table-cell{
display:table-cell;
vertical-align: middle;
text-align:left;
height: 100px;// your choose
}
add this to your css, hope it helps:
.weekly-middle img {
margin-top:50%;
}
.weekly-middle {
text-align: center;
width: 100%;
/* height:100%;*/
border: none;
border-collapse: collapse;
margin: 0px;
padding-top: 56px;
padding-bottom: 56px;
content: "";
display: table;
/*clear: both;*/
}
.weekly-middle img {
margin-top:50%;
}
.left {
text-align: left;
padding: 20px;
width: 100px;
float: left;
/* padding-top: 56px;
padding-bottom: 56px;*/
vertical-align: middle;
height: 300px
}
.right {
margin-left: 100px;
float: left;
padding-top: 56px;
padding-bottom: 56px;
}
<div class="weekly-middle teal">
<div class="left">
<img width="50" height="50" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f9/Wiktionary_small.svg/350px-Wiktionary_small.svg.png" />
</div>
<div class="right">
<h1>Some Title</h1>
<p class="title">Problems Solved</p>
</div>
</div>
I think you should be able to just remove the 'left' and 'right' classes from the inner divs and it will work.
See if what you're looking for is below.
.weekly-middle {
text-align: center;
width: 100%;
/* height:100%;*/
border: none;
border-collapse: collapse;
margin: 0px;
padding-top: 56px;
padding-bottom: 56px;
content: "";
display: table;
/*clear: both;*/
}
.left {
text-align: left;
padding: 20px;
width: 100px;
float: left;
/* padding-top: 56px;
padding-bottom: 56px;*/
vertical-align: middle;
height: 300px
}
.right {
margin-left: 100px;
float: left;
padding-top: 56px;
padding-bottom: 56px;
}
<div class="weekly-middle teal">
<div class="">
<img width="50" height="50" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f9/Wiktionary_small.svg/350px-Wiktionary_small.svg.png" />
</div>
<div class="">
<h1>Some Title</h1>
<p class="title">Problems Solved</p>
</div>
</div>

make div and image vertically align inside a div

<div class="outside" style="width: 500px; height: 20px; border: 1px solid red;">
<img src="" style="width: 10px; height: 20px; margin: 0; padding: 0; display: inline-block;">
<div id="here" style="display: inline-block; height: 15px; border: 1px solid blue; font-size: 7px;">11</div>
</div>
I found bottom line of img and #here do not in a line, if I add any text to #here, who can tell me why.
And how to make the #here and img verticall center in the outside (img and #here in the same line )
vertical-align is what you are looking for.
.outside > * {
vertical-align: middle;
}
<div class="outside" style="width: 500px; height: 20px; border: 1px solid red;">
<img src="http://www.fillmurray.com/20/10" style="width: 10px; height: 20px; margin: 0; padding: 0; display: inline-block;">
<div id="here" style="display: inline-block; height: 15px; border: 1px solid blue; font-size: 7px;">11</div>
</div>
Do you want it in the horizontal center?
#ImageCtr {
width: 10px;
height: 20px;
}
#outer {
width: 500px;
height: 20px;
background-color: #FF0000;
display: flex;
align-items: center;
justify-content: center;
}
<div id="outer">
<div id="ImageCtr"><img src="http://i.imgur.com/vCVDBHB.png">
</div>
</div>

Vertical align image in center div

I would like to vertical align a image in the center of a div.
For this I use this code:
<div id="cboxLoadedContent" style="width: 1024px; overflow: auto; height: 738px; vertical-align: middle;">
<img class="cboxPhoto" src="" style="cursor: pointer; float: none; width: 50%; vertical-align: middle;"></img>
</div>
JSFiddle: http://jsfiddle.net/3uk642wg/
How can I achieve that?
div#cboxLoadedContent {
....
display: table-cell;
text-align: center;
vertical-align: middle;
}
jsfiddle - http://jsfiddle.net/3uk642wg/1/
div#cboxLoadedContent {border: 1px solid #333; display: inline-block;text-align: center; display: table-cell;vertical-align: middle;}
.cboxPhoto {vertical-align: middle;}
<div id="cboxLoadedContent" style="width: 1024px; overflow: auto; height: 738px; vertical-align: middle;">
<img class="cboxPhoto" src="https://www.google.com//images/srpr/logo11w.png" style="cursor: pointer; float: none; width: 50%; vertical-align: middle;"></img>
</div>
If you are running this on modern browsers you can try this.
div#cboxLoadedContent {
border: 1px solid #333;
display: inline-block;
text-align: center;
}
.cboxPhoto {
position: relative;
top: 50%;
transform: translateY(-50%);
}

Float left div inside center container

All...
I want to ask very basic CSS. Please see here http://jsfiddle.net/fzJ8X/5/
HTML:
<div class="container">
<div class="item">
<div class="overlay">
<img src="http://placehold.it/200x200" />
</div>
</div>
<div class="item">
<div class="overlay">
<img src="http://placehold.it/200x200" />
</div>
</div>
<div class="item">
<div class="overlay">
<img src="http://placehold.it/200x200" />
</div>
</div>
CSS:
.container {
width: 500px;
margin: 0 auto;
text-align: center;
border: #000 1px solid;
}
.item {
display: inline-block;
border: #F00 5px solid;
width: 200px;
height: 200px;
text-align: left;
}
.overlay {
border: #00F 5px solid;
width: auto;
height: auto;
}
.item img{
max-width: 100%;
height: auto;
display: block;
}
I have three boxes inside container with style text-align:center. Now all boxes centered like I want, but how to all boxes in float left? like screenshot below :
Screenshot here
Thank you very much :)
Try this:
JS iddle: http://jsfiddle.net/xZst7/3/
CSS:
.container {
width: 500px;
margin: 0 auto;
text-align: center;
border: #000 1px solid;
display: inline-block;
}
.item {
display: inline-block;
border: #F00 5px solid;
width: 200px;
height: 200px;
text-align: left;
float: left;
margin-right: 5px;
margin-bottom: 5px;
}
.overlay {
border: #00F 5px solid;
width: auto;
height: auto;
}
.item img{
max-width: 100%;
height: auto;
display: block;
}
HTML:
<div style="text-align: center;">
<div class="container">
<div style="display: inline-block; width: 430px;">
<div class="item">
<div class="overlay">
<img src="http://placehold.it/200x200" />
</div>
</div>
<div class="item">
<div class="overlay">
<img src="http://placehold.it/200x200" />
</div>
</div>
<div class="item">
<div class="overlay">
<img src="http://placehold.it/200x200" />
</div>
</div>
</div>
</div>
</div>
add float:left; to the code
.item {
display: inline-block;
border: #F00 5px solid;
width: 200px;
height: 200px;
text-align: left;
float:left;
}
jsfiddle:http://jsfiddle.net/fzJ8X/12/
Nothing much to do.
Add float:left; to .item{} as below.
.item {
display: inline-block;
border: #F00 5px solid;
width: 200px;
height: 200px;
text-align: left;
float:left;
}
Check the fiddle
Fiddle