官术网_书友最值得收藏!

Defining base rules

Firstly, we will create a Base directory and place the reset styles in there:

./assets/css/Base/base.css

html { 
-webkit-font-smoothing: antialiased;
}

* {
box-sizing: border-box;
}

nav > ul {
list-style: none;
padding: 0;
margin: 0;
}

body {
min-height: 100vh;
margin: 0;
font-family: Arial;
}

.is-hidden {
display: none !important;
}

For HTML scope, we will enable font smoothing for better font rendering.

Then, we will set box sizing of every element (*) in border-box. The default CSS box model is content-box, where width and height set to an element do not include padding and border. However, if we are setting, let's say, a sidebar width 250px, I would expect it to cover this length. With border-box, the box's size is always exactly what we set it, regardless of padding or border, but if you ask me, the border-box mode feels more natural.

We will reset indents and markers--for an unordered list--that are used for navigation (nav > ul). We make body element span the height of the entire viewport (min-height: 100vh), remove the default margin, and define the font family.

We will also introduce a global state is-hidden that can be applied on any element to remove it from the page flow. By the way, that is a good example of proactive and, therefore, permissible use of !important. By adding an is-hidden class (with JavaScript), we state that we want the element to hide, with no exceptions. Thus, we will never run into a specificity problem.

主站蜘蛛池模板: 东乡县| 梁山县| 天镇县| 苍山县| 贡觉县| 布尔津县| 五寨县| 建平县| 阜新| 澄迈县| 托里县| 昭通市| 阳东县| 上虞市| 汾阳市| 沁水县| 师宗县| 宁国市| 罗甸县| 玉环县| 东乡族自治县| 会理县| 迁安市| 五莲县| 长汀县| 虞城县| 敦煌市| 灯塔市| 云梦县| 北碚区| 噶尔县| 通道| 高平市| 彩票| 锦州市| 双辽市| 东乌珠穆沁旗| 蓝山县| 囊谦县| 蚌埠市| 阳泉市|