Style CSS for logo and text on same line - html

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/2wCEAAkGBxAQEBAPDxIPDQ8PDg8QDQ8PDw8PDw0PFRcWFhURFRUYHSggGB0lGxUVITEhJSktLi4uFx8zODMsNyguL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L/k69fE/YofGoWuPlnfhNSIi6GQiIgIiICIiAiIgIiICIiAiIgIiIPFy5rGH2tiHvTvpauo1y/rFH2tX+8u8GrLLw0x8tasllU2U2Vzba6U7KnYsN2i7Tm5g3jtb/hXOymypixpVppA4XBBCvGBYowkHaYdh3H8Lu8K5grwCGyjozwJzYe53+VlfHvrVrW8d2TYFcMaqEbrq4jXFZ0QqNYriOJfERV9AAue9tLxD2GFXsMC9hjCvYY1xZMjWIfMUCuG0/YrhsbWNMkjmxxtzc97gxjR2uOQWtY1pxGwFlC0TP3ecyNIhb2sac5D2mw71lixZc86pG/nt/at8lacsjjmIQ0UYfLdz336GFv8AqSns5N5uOQ7Tko1xKukqJDLKQXEWa1vUiZ+Bv9TxSolfI90kr3SyP68jzdx7OwdgyCp7K+g8J4WuCPe08z/jhyZZvPwpWSyqbKbK69stKVlL/k79fE/YofGpUS7Klzyeh6eJexQ+NQtMU/kpeOiZkRF1MRERAREQEREBERAREQEREBERAREQFzHrDb9q1/vLvALpsrmjWCPtSu95d4BYZ/S0xctb2U2VVsllybb6U9lebKq2SybFPZXhZfI2I5HMKrZLJsWzINnONzouwG7P4SrmOtnbvEco7C6N39QlkskzE8xsjccLiPGCN8Mg9lzHf1V1HpAB+qn/AIY/+Sxtkss5xY57LxkvHdmRpSR1ad59uRjB+V1Tl0pqzcM6GnHAtYZXj4vy/wBqxVksqx4fDH8Y/f7TOS893lXNJM4OnkkqHDqmVxcG+y3c34BfGyqlkstt9melPZTZVSyWTYp7K82VVsvLJs0p7Klnyfh6eJexQ+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>

Related

align div horizontally after screen resize using css

I'm trying to align div horizontally as the browser resizes, currently, I have 3 divs. As per the requirement, I can add an additional div. My problem is as soon I increase the window size above 2500, the right side of the screen becomes empty & all the divs are floating to left. As I cannot set the div width to 30-33% as per the requirement. Below is my code. kindly help.
div.box-container {
mc-grid-row: true;
margin-left: auto;
margin-right: auto;
float: left;
display: flex;
width: 100%
}
div.box {
float: left;
background-color: #ffffff;
position: relative;
padding: 10px;
box-sizing: border-box;
height: 326px;
margin-left: 20px;
margin-bottom: 0;
top: 55px;
border-top-right-radius: 0px;
width: 30%;
border: 1px solid #cccccc;
}
<div class="box-container">
<div class="box">
<p>jfn,mnfngf,mn,mgfnbgnkjdkjgkdg</p>
</div>
<div class="box">
<p>jfn,mnfngf,mn,mgfnbgnkjdkjgkdg</p>
</div>
<div class="box">
<p>jfn,mnfngf,mn,mgfnbgnkjdkjgkdg</p>
</div>
</div>
As #Arman Ebrahimi had already mentioned correctly. Use flex box only. The issue of responsibility can be handled well with media queries.
Working example
* {
box-sizing: border-box;
}
div.box-container {
display: flex;
flex-wrap: wrap;
font-size: 30px;
text-align: center;
gap: 10px;
width: 80%;
margin: 0 auto;
/* or use justify-content: center; */
}
.box {
background-color: #f1f1f1;
padding: 10px;
flex: 30%;
border: 1px solid #cccccc;
word-break: break-word;
height: 326px;
}
#media (max-width: 800px) {
.box {
flex: 100%;
}
}
<div class="box-container">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
<div class="box">5</div>
<div class="box">6</div>
</div>
Remove float and only use flex:
* {
box-sizing: border-box;
}
body,
html {
margin: auto;
}
div.box-container {
mc-grid-row: true;
margin-left: auto;
margin-right: auto;
display: flex;
width: 100%;
}
div.box {
background-color: #ffffff;
padding: 10px;
height: 326px;
margin-left: 20px;
margin-bottom: 0;
top: 55px;
border-top-right-radius: 0px;
width: calc(100vw / 3);
/*calc(100vw / number of div)*/
border: 1px solid #cccccc;
word-break: break-word;
}
<div class="box-container">
<div class="box">
<p>jfn,mnfngf,mn,mgfnbgnkjdkjgkdg</p>
</div>
<div class="box">
<p>jfn,mnfngf,mn,mgfnbgnkjdkjgkdg</p>
</div>
<div class="box">
<p>jfn,mnfngf,mn,mgfnbgnkjdkjgkdg</p>
</div>
</div>
Use justify-content: center; when you are using flex. This means the flexed contents will always be centered on all screen types.
div.box-container {
mc-grid-row: true;
margin-left: auto;
margin-right: auto;
display: flex;
gap: 10px;
justify-content: center;
width: 100%
}
div.box {
background-color: #ffffff;
position: relative;
padding: 10px;
box-sizing: border-box;
height: 326px;
margin-bottom: 0;
top: 55px;
border-top-right-radius: 0px;
width: 33.33%;
border: 1px solid #cccccc;
}
body {
margin: 0;
}
<div class="box-container">
<div class="box">
<p>jfn,mnfngf,mn,mgfnbgnkjdkjgkdg</p>
</div>
<div class="box">
<p>jfn,mnfngf,mn,mgfnbgnkjdkjgkdg</p>
</div>
<div class="box">
<p>jfn,mnfngf,mn,mgfnbgnkjdkjgkdg</p>
</div>
</div>
Edit ~ add another div, reduce the % the div covers. Demonstrate min-width responsiveness.
div.box-container {
mc-grid-row: true;
margin-left: auto;
margin-right: auto;
display: flex;
flex-wrap: wrap;
gap: 10px;
justify-content: center;
width: 100%
}
div.box {
background-color: #ffffff;
position: relative;
padding: 10px;
box-sizing: border-box;
height: 326px;
margin-bottom: 0;
top: 55px;
border-top-right-radius: 0px;
width: 24%;
min-width: 300px;
border: 1px solid #cccccc;
}
body {
margin: 0;
}
<div class="box-container">
<div class="box">
<p>jfn,mnfngf,mn,mgfnbgnkjdkjgkdg</p>
</div>
<div class="box">
<p>jfn,mnfngf,mn,mgfnbgnkjdkjgkdg</p>
</div>
<div class="box">
<p>jfn,mnfngf,mn,mgfnbgnkjdkjgkdg</p>
</div>
<div class="box">
<p>jfn,mnfngf,mn,mgfnbgnkjdkjgkdg</p>
</div>
</div>

How to algin text inside div element using flexbox?

I want to add text at bottom right corner inside card element. The text which I want to enter is Innings and Average. I have created flex-box but text such as innings and average is not getting displayed in bottom right corner.
Code:
.playercard1 {
display: flex;
align-items: flex-start;
height: 120px;
width: 500px;
margin-top: 30px;
margin-left: 30px;
}
.item {
padding-left: 10px;
}
.info {
margin-top: 25px;
}
<div class="playercard1">
<img class="profilepic" src="./profile.jpg">
<div class="item">
<div class="info">
<h6>Naman Kohli, Team Name, Right-Hand bat</h6>
<h2 className="cardtitle1">150</h2>
<p>Innings:5</p>
<p>Average:40.67</p>
</div>
</div>
</div>
In my screenshot you can see the innings and average is not getting displayed at bottom right corner. Check screenshot below:
What I am trying to achieve see in below screenshot I want to display innings and average at bottom right corner like the one in below screenshot.
Here is my solution, its not perfect, but it will give you a starting point
.playercard1 {
display: flex;
align-items: flex-start;
height: auto;
width: 500px;
margin-top: 30px;
margin-left: 30px;
border: 1px solid black;
padding: 10px;
}
.item {
padding-left: 10px;
flex:1;
}
.info {
margin-top: 25px;
}
.flex{
display:flex;
justify-content:space-between;
}
.cardtitle1{
font-size:24px;
}
<div class="playercard1">
<img class="profilepic" src="https://placehold.it/100x100">
<div class="item">
<div class="info">
<div>Naman Kohli, Team Name, Right-Hand bat</div>
<div class="flex">
<div class="cardtitle1">150</div>
<div>
<div>Innings:5</div>
<div>Average:40.67</div>
</div>
</div>
</div>
</div>
</div>
With position:absolute
.playercard1 {
display: flex;
align-items: flex-start;
height: auto;
width: 500px;
margin-top: 30px;
margin-left: 30px;
border: 1px solid black;
padding: 10px;
position: relative;
}
.item {
padding-left: 10px;
flex: 1;
}
.info {
margin-top: 25px;
}
.flex {
display: flex;
justify-content: space-between;
}
.cardtitle1 {
font-size: 30px;
margin-top:25px;
}
.absolute {
position: absolute;
bottom: 10px;
right: 15px;
}
<div class="playercard1">
<img class="profilepic" src="https://placehold.it/80x80">
<div class="absolute">
<div>Innings:5</div>
<div>Average:40.67</div>
</div>
<div class="item">
<div>Naman Kohli, Team Name, Right-Hand bat</div>
<div class="cardtitle1">150</div>
</div>
</div>
.playerCard{
display: flex;
align-items: flex-start;
height: 120px;
width: 500px;
margin-top: 30px;
margin-left: 30px;
box-shadow: 0 1px 2px rgba(0,0,0,0.4);
padding: 15px;
}
.playerCard .player_profile_pic{
display: inline-block;
vertical-align: top;
border-radius:50px;
}
.playerCard .player_profile_pic img{
border-radius: 100%;
width: 100px;
height: 100px;
}
.playerCard .player_details_div{
display: inline-block;
vertical-align: top;
margin-top: 10px;
margin-left: 15px;
width: calc(100% - 30px);
}
.player_details_div .player_name_det{
font-size: 16px;
}
.player_details_div .rank_ings_main_div{
width: 100%;
}
.rank_ings_main_div .number_div{
font-size: 30px;
text-align: left ;
float: left;;
}
.rank_ings_main_div .avg_ings_div{
float: right;
text-align: right;
}
.avg_ings_div p{
margin: 5px 0;
}
<div class="playerCard">
<div class="player_profile_pic">
<img src="https://i.stack.imgur.com/l60Hf.png" alt="">
</div>
<div class="player_details_div">
<div class="player_name_det">
Naman Kohli , Team Name, Right Hand Bat
</div>
<div class="rank_ings_main_div">
<div class="number_div">150</div>
<div class="avg_ings_div">
<p>Innings : 3</p>
<p>Average : 50.00</p>
</div>
</div>
</div>
</div>
I guess you need something like this.
Hope this helps.

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.

How to synchronize heights of to elements

How can I synchronize the height of an image with the height of a text area, depending on the screen size? I do not want to use the left border of the text area because I want a visual separation between the left bar and the text. I do not want the width of the bar to be adjusted simultaneously, because it is only a visual separator in the page; the bar should be just as long as the text on its right side.
NB: the bar is not restricted to an image; it can be anything as long as the result is a colored vertical bar with the correct height.
html {
height: 100%;
margin: 0;
padding: 0;
}
body {
background-color: #fff8dc;
color: grey;
font-family: Arial;
font-size: 1em;
position: relative;
min-height: 100%;
}
.common {
background-color: #fff8dc;
float: left;
width: 25%;
height: 100vh;
text-align: center;
padding: 0 40px 10px 40px;
}
.detail {
background-color: #fff8dc;
float: left;
margin: 0 20px 0 0;
overflow: auto;
height: 100%
}
.text {
margin: 0px 40px 0px 40px;
background-color: #ffffff;
padding: 10px 20px 10px 20px;
}
<div class="common">
<p>blabla</p>
</div>
<div>
<div class="detail">
<img src="widgets/spacer.gif" alt="vertical bar" width="30px" height="400px" style="background-color: #E3B90A;">
</div>
<div class="text">
<h1>BLABLA</h1>
<p>blablabla</p>
<p>blablabla</p>
<p>blablabla</p>
</div>
</div>
You can do it this way:
HTML:
<div class="common">
<p>blabla</p>
</div>
<div class="container">
<div class="detail">
<img src="widgets/spacer.gif" alt="vertical bar">
</div>
<div class="text">
<h1>BLABLA</h1>
<p>blablabla</p>
<p>blablabla</p>
<p>blablabla</p>
</div>
</div>
CSS:
html {
height: 100%;
margin: 0;
padding: 0;
}
body {
background-color: #fff8dc;
color: grey;
font-family: Arial;
font-size: 1em;
position: relative;
min-height: 100%;
}
.container{
display: flex;
flex-direction: row;
}
.common {
background-color: #fff8dc;
float: left;
width: 25%;
height: 100vh;
text-align: center;
padding: 0 40px 10px 40px;
}
.detail {
background-color: #E3B90A;
width: 30px;
height: auto;
}
.detail img{
width: 100%;
height: auto;
}
.text {
width: 100%;
background-color: #ffffff;
padding: 10px 20px 10px 20px;
}
Fiddle: https://jsfiddle.net/debraj/s84yxh8L/

My vertical align of image doesnt work

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.