I googled and tried different solutions but couldn’t get text vertically aligned on top right side of an image.
mainly played around with transform
, translate
, writing-mode
properties but couldn’t place text at exact location.
Please help
I googled and tried different solutions but couldn’t get text vertically aligned on top right side of an image.
mainly played around with transform
, translate
, writing-mode
properties but couldn’t place text at exact location.
Please help
Could you share a demo code? You want the Product owener
to be on the image of top right corner?
<div class="profiles">
<div class="first">
<div class="img-container">
<p>PRODUCT OWNER</p>
<img src="images/photo1.png">
<p>Bill Mahoney</p>
</div>
.....
.img-container {
display: inline-block;
vertical-align: top;
text-align: center;
box-sizing: border-box;
width: 350px;
height: 450px;
padding: 25px 12px;
margin-bottom: 40px;
}
div > img {
width: 300px;
height: 400px;
}
.img-container > p:first-of-type {
color: red;
text-align: right;
}
Requirement is Product owner
should be shown vertical outside
of the image vertically as per attachment shared earlier
<div class="profiles">
<div class="first">
<div class="img-container">
<p>PRODUCT OWNER</p>
<img src="images/photo1.png">
<p>Bill Mahoney</p></div>
</div>
</div>
<div>
.img-container {
display: inline-block;
vertical-align: top;
text-align: center;
box-sizing: border-box;
width: 350px;
height: 450px;
padding: 25px 12px;
margin-bottom: 40px;
}
div > img {
width: 300px;
height: 400px;
}
.img-container > p:first-of-type {
color: red;
position: absolute;
transform: rotate(90deg);
left: 280px;
top: 80px;
}
Is this what you want?
no, your solution didn’t work. Can you check PRODUCT OWNER
text against the image ?
Your solution is using position: absolute
which is placing text at top of image at random place.
There are in total 6 images and I need to place their designation
<div class="profiles">
<div class="first">
<div class="img-container">
<p>PRODUCT OWNER</p>
<img src="images/photo1.png">
<p>Bill Mahoney</p>
</div>
</div>
</div>
<div class="second">
<div class="img-container">
<p>PRODUCT OWNER 2</p>
<img src="images/photo1.png">
<p>Bill Mahoney</p>
</div>
</div>
</div>
<div>
.img-container {
padding: 25px 12px;
margin-bottom: 40px;
position: relative;
}
div > img {
width: 300px;
height: 400px;
}
.img-container > p:first-of-type {
color: red;
position: absolute;
transform: rotate(90deg);
left: 260px;
top: 80px;
}
What about this one? Check out demo on codepen
Thanks, now I’ve exactly same code like yours but it’s showing like below
Why is words not in single line ?
Why are they overlapping image ?
sometimes CSS is really big mystery and hard to find where am I going wrong
Check the codepen again.
You need to practise and play around with styles.
You should be able to use writing-mode
. But it does seem like you get some overflow. I would need to see it in some different contexts to know how that might affect things.
Thanks, so if I understand correctly
absolute
position and width of 100%
along with rotate did the trick right ?
This is also a nice solution, thanks for sharing.
In this case yes. Remember that we also used position: relative;
in the container.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.