gpt4 book ai didi

html - 将图像样式设置为位于 div 的右上角

转载 作者:太空宇宙 更新时间:2023-11-04 10:33:23 24 4
gpt4 key购买 nike

我想将图像样式设置为位于 div 的右上角,如何实现?请帮忙。 I want to style this to reflect this screenshot

<html>
<head>
<style>
.first{
width: 200px;
height: 200px;
color: blue;
border: blue;
border-style: solid;
border-color: blue;
background: blue;
}
</style>
</head>

<body>
<div class="first">testing this forum
</div>
</body>
</html>

最佳答案

div {
height: 175px;
width: 175px;
background: blue;
position: relative;
/* Additionally padding? */
}

div > img {
height: 25px;
width: 25px;
position: absolute;
top: 0px; right: 0px;
/* Change top < 0 and right < 0 to be outside */
}
<div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque velit elit, tempus non suscipit id, pretium a mi. Aliquam erat volutpat.
<img src="http://maciejczyzewski.me/assets/images/prints/head.jpeg" />
</div>

关于html - 将图像样式设置为位于 div 的右上角,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36361079/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com