根据标签自身属性重新整理了一下reset css,方便后面开发时使用

本文详细介绍了CSS样式重置的重要性和具体实践,包括通用标签的样式重置,如body、p、ul等,以及fieldset和legend的特殊处理。此外,还探讨了a标签的四种状态样式设置,确保用户体验和无障碍访问。通过对这些基础样式的优化,可以提高网页的一致性和可维护性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 真正需要重置的标签也就下面这些,其它的直接用默认属性即可,完全没必要重置。
html, body {
  min-height: 100vh;
}
body, p, ul, ol, dl, dd, h1, h2, h3, h4, h5, h6, pre, hr, fieldset, figure, menu {
  margin: 0;
}
ul, ol, th, td, button, input, textarea, menu {
  padding: 0;
}
ul {
 list-style-type: none;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
}
hr {
  border-bottom: none;
}
button, input, textarea, iframe {
  border: none;
}
button, input, textarea {
  background-color: transparent;
}
button:focus, input:focus, textarea:focus {
  outline: none;
}
textarea {
  width: auto;
  height: auto;
  resize: none; /* 不允许手动拉伸 */
}
iframe {
  display: block;
}
img {
  vertical-align: bottom;
}
2. fieldset标签与legend 单独处理一下,具体根据需要设置
fieldset {
  padding: 10px 20px;
  text-align: center;
  border-width: 1px;
}
legend {
  padding: 0 10px;
}
3. a标签各个点击状态单独处理,具体根据需要设置
/****
设置a标签的样式须遵循link-visited-hover-active顺序;
没有href属性,将没有a:link和a:visited的状态;
只设置a的样式,不设置四种状态的样式,那么四种状态会都继承a的样式;
****/
a {
  text-decoration: none;
}
a:link {
  color: blue;
}
a:visited { /* 已点击状态 */
  color: green;
}
a:hover { /* 鼠标悬停状态 */
  color: yellow;
  text-decoration: underline;
}
a:active { /* 点下去的时的状态 */
  color: red;
}

其它标签根据实际情况做单独调整即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值