CSS(Cascading Style Sheets,层叠样式表)是一种用来描述HTML或XML(包括SVG、MathML等各种XML方言)文档样式的样式表语言。CSS可以控制网页的布局和外观,使得网页更加美观和易用。
style
属性定义样式。style
属性定义样式。<head>
部分使用<style>
标签定义样式。<head>
部分使用<style>
标签定义样式。<link>
标签引入。<link>
标签引入。box-sizing: border-box;
统一盒模型计算,使用clear: both;
或Flexbox、Grid布局解决浮动问题。-webkit-
、-moz-
等),使用Autoprefixer等工具自动添加前缀。<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>手机网站CSS示例</title>
<style>
body {
font-family: Arial, sans-serif;
}
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
}
.box {
width: 200px;
height: 200px;
background-color: #007bff;
color: white;
display: flex;
justify-content: center;
align-items: center;
font-size: 24px;
transition: background-color 0.5s;
}
.box:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="container">
<div class="box">点击我</div>
</div>
</body>
</html>
领取专属 10元无门槛券
手把手带您无忧上云