如何使用 CSS 将文字定位到图片的右上角
若要将文本定位到右上角,请使用 right 和 top 属性。你可以尝试运行以下代码来实现它
示例
<!DOCTYPE html>
<html>
<head>
<style>
.box {
position: relative;
}
img {
width: 100%;
height: auto;
opacity: 0.6;
}
.direction {
position: absolute;
top: 10px;
right: 19px;
font-size: 13px;
}
</style>
</head>
<body>
<h1>Heading One</h1>
<p>Below image has text in the top right:</p>
<div class = "box">
<img src = "https://tutorialspoint.com/python/images/python_data_science.jpg" alt = "Tutorial"
width = "800" height = "400">
<div class="direction">Top Right Corner</div>
</div>
</body>
</html>
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言
C++
C#
MongoDB
MySQL
Javascript
PHP