Study notes-some public styles in CSS


In CSS, we may reuse some styles many times, we will put these styles in a separate folder, and use them. This greatly improves the reusability of the code and reduces the occurrence of duplicate codes.

1. Reset style:

/* 复位 */
* {
    margin: 0;
    padding: 0;
}

/* 去除小黑点 */
ul {
    list-style: none;
}

/* 去除下划线 */
a {
    text-decoration: none;
}

2. Common styles:

// 页面最上面的导航栏
.tonglan {
    width: 100%;
    min-width: 1200px;
}

.w {
    width: 1200px;
    margin: 0 auto;    /* 块级元素水平居中 */     
}

/* 单行文本省略 */
.ellipsis {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 多行文本省略  有兼容性 */
.rows-ellipsis {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 清除浮动 */
.clearfix::after {
    content: '';
    display: block;
    width: 0;
    height: 0;
    clear: both;
}

 You can also dynamically add some styles to the common styles according to your needs, such as adding page headers and footers.

Guess you like

Origin blog.csdn.net/qq_41339126/article/details/109397807