CSS中有一些元素,在页面中经常被单独加上样式。以下就是其中比较常见的一些元素。
/* 1. 链接 */
a {
color: blue;
text-decoration: none;
border-bottom: 1px solid blue;
}
/* 2. 列表 */
ul, ol {
list-style-type: none;
margin: 0;
padding: 0;
}
li {
margin-bottom: 10px;
}
/* 3. 图像 */
img {
max-width: 100%;
height: auto;
}
/* 4. 表格 */
table {
border-collapse: collapse;
}
td, th {
border: 1px solid black;
padding: 5px;
}
/* 5. 表单 */
input[type="text"], textarea {
border: 1px solid black;
padding: 5px;
} 对于链接元素a,我们通常会改变其文字颜色、去除下划线并添加一条底边。列表元素ul和ol通常会被去除原本的列表样式,以及设置上下间距。图片元素img通常会被设置宽度最大为其容器宽度,并且保持高度自动适应。表格元素table通常需要与其内部td和th元素一起被样式化,以去除边框间的空隙。对于表单元素,我们通常会为常见输入框text与文本域textarea设置一致的边框和内边距。