使用 CSS 将列表项向右浮动
cssweb developmentfront end technology更新于 2024/7/6 14:36:17
要将列表项向右浮动,请在 CSS 中使用 float: right 属性。您可以尝试运行以下代码来实现:
示例
<!DOCTYPE html>
<html>
<head>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
li {
float: left;
}
li a {
display: block;
padding: 8px;
background-color: orange;
}
</style>
</head>
<body>
<ul>
<li><a href = "#home">Home</a></li>
<li><a href = "#news">News</a></li>
<li style = "float:right"><a href = "#contact">Contact</a></li>
<li style = "float:right"><a href = "#about">About</a></li>
</ul>
</body>
</html>
相关文章
有用资源
css 参考教程 - 该教程包含有关 css 的更多信息:https://www.cainiaomax.com/css/

