I am not getting how to float the second division to the upper right corner of the main division.
html {
width: 100%;
height:100%;
}
body {
width: 100%;
height: 100%;
font-family: 'Noto Sans', sans-serif;
background-color: #1b1b1b;
}
.container {
background-color: #313131;
width: auto;
height: calc(100%-30%);
padding: 20px;
}
.img-wrapper {
width: 144px;
height: 216px;
}
img {
width: 100%;
height: 100%;
}
.pfmr-info {
float: right;
}
<div class="container">
<div class="img-wrapper">
<picture>
<source
srcset="https://lh3.googleusercontent.com/d/1nGd_KYCiywe7k5upLO7OcVJCNtbtwRqB=w2000?authuser=0" media="(orientation: portrait)" />
<img
src="https://lh3.googleusercontent.com/d/1nGd_KYCiywe7k5upLO7OcVJCNtbtwRqB=w2000?authuser=0" alt="Cherie Deville" />
</picture>
</div>
<div class="pfmr-info">
<span style="color: #848484;font-size: medium;">Cherie Deville</span>
</div>
</div>
I need the second div to move to the upper-right corner but it just moves to the right. What should I do?
2
Answers
float
shouldn’t be use in that situation. Instead, you can applydisplay: flex
to your.container
. One of the default settings for flex isjustify-content: flex-start
, which (judging from your description) is most likely what you want. Otherwise you could add that parameter and change its setting. Alsoalign-items
is a setting you might wat to change from its defaultnormal
tobaseline
orcenter
(just try that to see the effects).Additionally, you might want to add some
margin-left
to.pfmr-info
to create a little distance between the image and the name. (see my example below)