CSS
学习
选择器
/*元素选择器*/
html {
}
/*类选择器*/
.gray {
}
/*id选择器*/
#unique {
}
/*伪类选择器*/
a:hover {
}
/*伪元素选择器*/
ul ::marker {
}
/*运算符选择器 选择了<article>元素的初代子元素*/
article > p {
}
字体设置
常用几个如下:其它的font开头的省略
px
body {
font-size: 22px;
font-family: Arial, Helvetica, sans-serif;
font-weight: 300;
}
em
rem
h1 {
border: 2px dashed red;
width: 50%;
/* rem base the root element
and em base the itself fontsize */
font-size: 3rem;
padding: 0.5em;
}
如何使用外部字体
@import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');
body {
padding: 25%;
font-size: 2rem;
}
/* input, button {
font: inherit;
} */
p {
/* text-transform: capitalize;
text-align: right; */
/* text-indent: 2em; */
/* line-height: 1.5; */
/* letter-spacing: 0.1em; */
/* word-spacing: 0.1em; */
/* font-weight: 900; */
/* font-style: italic; */
/* font-family: 'Courier New', Courier, monospace; */
font-family: 'Roboto', sans-serif;
}
盒子设置
box-sizing: content-box;: 这是默认值。在这种模型下,
元素的宽度和高度仅包括内容区域,不包括边框(border)、
内边距(padding)和外边距(margin)。这是传统的盒模型。
box-sizing: border-box;: 在这种模型下,
元素的宽度和高度包括了内容区域、边框和内边距,
但不包括外边距。
h1 {
box-sizing: border-box;
border: 2px dashed red;
}
.container {
border: 10px double red;
font-size: 1.5rem;
/* margin-top: 1.5em;
margin-right: 2em;
margin-bottom: 2em;
margin-left: 2em; */
/* margin: 1.5em 2em 2em; */
/* define the top right bottom left margin */
/* margin: 1em 2em 3em 4em; */
margin: 1.5em;
padding: 1.5em;
/*
border-top: 5px solid red;
border-right: 10px dotted green; */
outline: 5px solid purple;
outline-offset: -20px;
}
画圆
<div class="circle"></div>
.circle {
margin: 3rem auto;
background-color: gold;
width: 100px;
height: 100px;
border: 2px solid black;
outline: 2px solid red;
outline-offset: 0.25rem;
border-radius: 50%;
}