tensorflow CSS基本属性 - This is some text that will not wrap

📅 2026-12-01 👤 拼多多助力营销技巧 📂 拼多多助力2027 👁️ 345 次阅读

,需要子元素使用inherit继承关键字

Document

外边距塌陷

元素的上边距和下边距有时会合并成一个单独的边距,该边距等于两个边距中最大的边距,这不会发生在左右边距,只有上下边距

Document

Heading 1

Heading 2

内边距

填充用于在任何已定义的边框内围绕元素内容创建空间

内边距单面写法

Document

内边距四个值写法

Document

内边距三个值写法

Document

内边距两个值写法

Document

元素宽度和内边距

如果元素有指定的宽度,则添加到该个元素的内边距将添加到该元素的总宽度中,不推荐这种使用方式,为了保证宽度为300px,无论填充量多少,都可以使用box-sizing属性。这将导致元素保持其实际宽度;如果增加填充,可用的空间就会减少。这个属性例子中并未体现,有兴趣可以自己动手试试

Document

宽高和最大宽度

设置宽高

高度和宽度属性不包括填充、边框或边距!他们设置了内填充区域的高度/宽度,元素边界和边距

Document

设置最大宽度

由于某种原因,在同一个元素上同时使用了width属性和max-width属性,并且width属性的值大于max-width属性的值;max-width属性将使用(width属性被忽略)

Document

盒模型

在CSS中,在讨论设计和布局时使用专业术语叫做"盒模型",CSS框架本质上是一个包裹每个HTML元素的框。它包括: 内容、填充、边框和边距。

盒模型允许我们在元素周围添加边框,并定义元素之间的空间。

Content-显示文本和图像的边框内容

Padding-清除内容周围的区域。填充时透明的

Border-围绕填充和内容的边框

Margin-清除边界以外的区域。边距是透明的

元素的宽度和高度

为了在所有浏览器中正确设置元素的宽高,需要直到模型是如何工作的 CSS设置元素的宽高属性时,需要设置内容区域的宽高。来计算总数元素的宽高。还必须包括内边距(Border)和外边距(Margin)

Document

轮廓

轮廓是在元素边界外绘制的一条线,在边界外,使元素“突出”

CSS轮廓属性outline-style、outline-color、outline-width、outline-ofset、outline

Document

A dotted outline

A dashed outline

A solid outline

A double outline

A groove outline. The effect depends on the outline-color value.

A ridge outline. The effect depends on the outline-color value.

An inset outline. The effect depends on the outline-color value.

An outset outline. The effect depends on the outline-color value.

轮廓简写形式

Document

A dashed outline.

A dotted red outline.

A 5px solid yellow outline.

A thick ridge pink outline.

轮廓偏移量

outline-offset属性在元素的轮廓和边缘/边框之间添加空间。元素与其他轮廓之间的空间是透明的。

Document

This paragraph has an outline 15px outside the border edge.

CSS文本

文本颜色

Document

This is heading 1

This is an ordinary paragraph. Notice that this text is blue. The default text color for a page is defined in the

body selector.

Another paragraph.

文本背景颜色

始终确保文本颜色与背景颜色(或背景图像)之间的对比度良好

Document

文本对齐方式

文本对齐方式text-align、text-align-last、direction、unicode-bidi、vertical-align

水平居中

text-align属性用于设置文本的水平对齐方式,当text-align属性设置为"justify"时,每行被拉伸,使每行具有相同的宽度,并且左右边距是直的(像杂志和报纸),这个属性可以自己试一试

Document

Heading 1 (center)

Heading 2 (left)

Heading 3 (right)

The three headings above are aligned center, left and right.

文本最后对齐

text-align-last指定如何对齐文本的最后一行

Document

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam semper diam at erat pulvinar, at

pulvinar

felis blandit. Vestibulum volutpat tellus diam, consequat gravida libero rhoncus ut.

text-align-last: center:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam semper diam at erat pulvinar, at

pulvinar

felis blandit. Vestibulum volutpat tellus diam, consequat gravida libero rhoncus ut.

text-align-last: justify:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam semper diam at erat pulvinar, at

pulvinar

felis blandit. Vestibulum volutpat tellus diam, consequat gravida libero rhoncus ut.

文本方向

direction和unicode-bidi属性可以用来改变元素的文本方向

Document

This is right-to-left text direction.

垂直对齐

vertical-align设置元素的处置对齐方式

Document

An image with a default

alignment.

vertical-align: text-top:

An image with a text-top

alignment.

vertical-align: text-bottom:

An image with a text-bottom

alignment.

vertical-align: sub:

An image with a sub

alignment.

vertical-align: sup:

An image with a super

alignment.

文本装饰

添加装饰线

text-decoration-line属性用于向文本添加装饰线,可以组合多个值,如overline和underline,以显示文本上方和下方的行。

Document

Overline text decoration

Line-through text decoration

Underline text decoration

Overline and underline text decoration.

装饰线颜色

text-decoration-color属性用于设置装饰线的颜色

Document

Overline text decoration

Line-through text decoration

Underline text decoration

Overline and underline text decoration.

装饰线指定样式

text-decoration-style属性用于设置装饰线的样式

Document

Heading 1

Heading 2

Heading 3

A paragraph.

Another paragraph.

Another paragraph.

指定装饰线的厚度

text-decoration-thickness属性用于设置装饰线的厚度

Document

Heading 1

Heading 2

Heading 3

A paragraph.

装饰线简写形式

简写顺序text-decoration-line、text-decoration-color、text-decoration-style、text-decoration-thickness

小知识点: 默认情况下,HTML中的所有链接都带有下划线。有时需要样式不需要下划线。可以使用text-decoration: none;取消下划线

文本转换

文本转换属性用于指定文本中的大写字母和小写字母,它可以用来将所有元素变成大写或小写字母。

Document

This text is transformed to uppercase.

This text is transformed to lowercase.

This text is capitalized.

文本间距

文本缩进

text-indent属性用于指定文本第一行的缩进

Document

Using text-indent

In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever

since. 'Whenever you feel like criticizing anyone,' he told me, 'just remember that all the people in this world

haven't had the advantages that you've had.'

字符间距

letter-spacing属性用于指定文本中字符之间的间距

Document

This is heading 1

This is heading 2

行高

line-height用于指定行与行之间的间距

Document

This is a paragraph with a smaller line-height.

This is a paragraph with a smaller line-height.

This is a paragraph with a bigger line-height.

This is a paragraph with a bigger line-height.

字间距

word-spacing属性用于指定文本中单词与单词之间的间距

Document

This is a paragraph with larger word spacing.

This is a paragraph with smaller word spacing.

空格/空白

white-space这个属性和有意思,指定如何处理元素中的空白/空行。也就是HTML元素添加空行在页面效果也会展示出来,可以试试下面的例子去掉空行之后的效果

Document

This is some text that will not wrap.

This is some text that will not wrap.

This is some text that will not wrap.

This is some text that will not wrap.

This is some text that will not wrap.

This is some text that will not wrap.

This is some text that will not wrap.

This is some text that will not wrap.

This is some text that will not wrap.

文本阴影

text-shadow属性为文本添加阴影

Document

Text-shadow effect!

CSS字体

为网页选择合适的字体是很重要的!

字体

font-family来指定文本的字体,如果字体名称多于一个单词,必须用双引号包括起来,像"Times New Roman".

Document

This is a paragraph, shown in the Times New Roman font.

This is a paragraph, shown in the Arial font.

This is a paragraph, shown in the Lucida Console font.

网页安全字体

Web安全字体是在所有浏览器和设备上普遍安装的字体。总有设备上面找不到需要的字体,所以我们要设置备用字体,如果设备上没有第一种字体,浏览器会启用备用字体。

Document

This is a paragraph.

This is another paragraph.

以下是HTML和CSS的最佳网页安全字体

Arial (sans-serif)Verdana (sans-serif)Tahoma (sans-serif)Trebuchet MS (sans-serif)Times New Roman (serif)Georgia (serif)Garamond (serif)Courier New (monospace)Brush Script MT (cursive)

字体样式

font-style主要用于指定斜体文本,属性取值有三个:

normal: 文本正常显示italic:文本以斜体显示oblique: 文本倾斜

Document

This is a paragraph in normal style.

This is a paragraph in italic style.

This is a paragraph in oblique style.

字体粗细

font-weight指定字体的粗细

Document

This is a paragraph.

This is a paragraph.

This is a paragraph.

This is a paragraph.

字体大小写

font-variant属性指定文本是否应该以大小写字体显示

Document

My name is Hege Refsnes.

My name is Hege Refsnes.

字体大小

font-size设置文本的大小。字体大小值可以是绝对大小,也可以是相对大小。 绝对大小:

将文本设置为指定的大小不允许用户在所有浏览器中更改文本大小(不利于可访问性)当输出的物理大小已知时,绝对大小是有用的

相对大小:

设置相对于周围元素的大小允许用户在浏览器中更改文本大小

Document

This is heading 1

Specifying the font-size in em allows all major browsers to resize the text.

Unfortunately, there is still a problem with older versions of IE. When resizing the text, it becomes

larger/smaller

than it should.

使用百分比和Em的组合

使用于所有浏览器,就是为元素设置一个默认的以百分比为单位的字体大小,它在所有浏览其中显示相同的文本大小,并允许所有浏览器缩放或调整文本大小

响应式字体大小

文本字体可以用vm单位设置,这意味着"视口宽度",这样文本大小将随着浏览器窗口的大小改变。viewport是浏览器窗口的大小,1vm = 1%视口宽度。如果视口是50cm宽,1vw就是0.5cm

Document

Responsive Text

Resize the browser window to see how the text size scales.

Use the "vw" unit when sizing the text. 10vw will set the size to 10% of the viewport

width.

Google字体

使用谷歌字体,只需要在部分添加一个特殊的样式链接,然后引入CSS中的字体。当在CSS中指定字体时,总时列出至少一个备用字体(以避免意外行为),列表末尾应该添加一个通用的字体系列serif或sans-serif,使用Goole多种字体需要在后面用管道符|进行分割。

Document

Sofia Font

Lorem ipsum dolor sit amet.

123456790

炫酷的字体

Document

href="https://fonts.googleapis.com/css?family=Sofia&effect=neon|outline|emboss|shadow-multiple">

Neon EffectOutline EffectEmboss EffectMultiple Shadow Effect

字体搭配

优秀的字体搭配对于优秀的设计很重要

字体搭配规则

TODO: 正在寻找字体搭配规则…

Document

href="https://fonts.googleapis.com/css?family=Sofia&effect=neon|outline|emboss|shadow-multiple">

Beautiful Norway

Norway has a total area of 385,252 square kilometers and a population of 5,438,657 (December 2020). Norway is

bordered by Sweden, Finland and Russia to the north-east, and the Skagerrak to the south, with Denmark on the

other

side.

Norway has beautiful mountains, glaciers and stunning fjords. Oslo, the capital, is a city of green spaces and

museums. Bergen, with colorful wooden houses, is the starting point for cruises to the dramatic Sognefjord.

Norway

is also known for fishing, hiking and skiing.

CSS图标

通过使用图标库,可以和容易地将图标添加到HTML页面中 如何添加图标

向HTML页面添加图标的最简单方法是使用图标库,例如: Font Awesome已无法使用,可以使用Google icon下面例子使用的是Goole icon.将指定图标类的名称添加到任何内联HTML元素(如或)下面图标库中的所有图标都是可缩放的矢量,可以用CSS自定义(大小、颜色、阴影等)只需要引入图标库,不需要下载或安装,需要联网。如果本地使用需要下载,不需要联网

Document

Some Google icons:

cloud

favorite

attachment

computer

traffic

Styled Google icons (size and color):

cloud

cloud

cloud

cloud

CSS链接

使用CSS可以为链接设置各种各样的样式。链接可以使用任何CSS属性(例如: 颜色、字体、背景等)。链接可以使用a标签

Document

链接可以根据所处的状态设置不同的样式: a:link- 一个正常的,未访问的链接 a:visited- 用户访问过的链接 a:hover- 当用户将鼠标放在一个链接上时 a:active- 链接被点击的那一刻 当为几个链接状态设置样式时,有一些顺序规则:

a:hover必须出现在a:link和a:visited之后a:active必须在a:hover之后

Document

文本装饰

text-decoration属性主要用于移除链接中的下划线,也可以添加下划线

Document

背景颜色

background-color可以指定链接的背景颜色

Document

使用CSS做一个按钮链接

Document

不同类型游标展示可以用于链接

Document

auto

crosshair

default

e-resize

help

move

n-resize

ne-resize

nw-resize

pointer

progress

s-resize

se-resize

sw-resize

text

w-resize

wait

CSS列表

列表分有序列表(

标签表示)和无序列表(

标签表示),CSS可以使列表更加列表(列表更加规范/好看)

不同的列表标记

list-style-type指定列表标记的类型

Document

Coffee

Tea

Coca Cola

Coffee

Tea

Coca Cola

Coffee

Tea

Coca Cola

Coffee

Tea

Coca Cola

列表标记添加图片

list-style-image指定一个图像作为列表项的标记

Document

Coffee

Tea

Coca Cola

指定列表标记位置

list-style-position指定列表标记的位置,list-style-position: outside;表示项目符号将在列表项之外。列表项的每行开头将垂直对齐。这是默认值;list-style-position: inside;表示项目符号将位于列表内部,它是列表项的一部分

Document

Coffee - A brewed drink prepared from roasted coffee beans, which are the seeds of berries from the Coffea

plant

Tea - An aromatic beverage commonly prepared by pouring hot or boiling water over cured leaves of the

Camellia

sinensis, an evergreen shrub (bush) native to Asia

Coca Cola - A carbonated soft drink produced by The Coca-Cola Company. The drink's name refers to two of its

original ingredients, which were kola nuts (a source of caffeine) and coca leaves

Coffee - A brewed drink prepared from roasted coffee beans, which are the seeds of berries from the Coffea

plant

Tea - An aromatic beverage commonly prepared by pouring hot or boiling water over cured leaves of the

Camellia

sinensis, an evergreen shrub (bush) native to Asia

Coca Cola - A carbonated soft drink produced by The Coca-Cola Company. The drink's name refers to two of its

original ingredients, which were kola nuts (a source of caffeine) and coca leaves

删除默认列表标记

list-style-type:none;用来删除标记/符号。列表也有默认的边距和内边框。要删除这个,需要添加margin:0; padding:0;到

标签或

标签

Document

Coffee

Tea

Coca Cola

简写方式

简写顺序是: list-style-type、list-style-position、list-style-image

CSS表格

表格边框

要在CSS中指定表格边框,需要使用border属性

Document

Firstname

Lastname

Peter

Griffin

Lois

Griffin

宽屏表

在某些情况下,需要跨越整个屏幕(全宽)表,需要给标签添加

width:100%;

Document

Firstname

Lastname

Peter

Griffin

Lois

Griffin

解决双边框问题

上面的例子出现双边框的原因是因为表格以及和元素都有单独的边框。border-collapse属性是否将表格边框折叠为但边框

Document

Firstname

Lastname

Peter

Griffin

Lois

Griffin

CSS表格尺寸

width和height属性定义表的宽度和高度

Document

Firstname

Lastname

Savings

Peter

Griffin

$100

Lois

Griffin

$150

Joe

Swanson

$300

Cleveland

Brown

$250

表格对齐方式

水平对齐

text-align属性设置或中内容的水平对齐方式,例如左、右或居中。默认情况下,元素的内容是居中对齐,元素的内容是左对齐

Document

Firstname

Lastname

Savings

Peter 拼多多帮助力入口

Griffin

$100

Lois

Griffin

$150

Joe

Swanson

$300

Cleveland

Brown

$250

垂直对齐

verical-align属性设置或中内容的处置对齐方式,如顶部、底部或中间。默认情况下,表中内容的垂直对齐为中间。

Document

Firstname

Lastname

Savings

Peter

Griffin

$100

Lois

Griffin

$150

Joe

Swanson

$300

Cleveland

Brown

$250

表格样式

表填充

在和元素上使用padding属性来控制表格中边框和内容之间的间距

Document

Firstname

Lastname

Savings

Peter

Griffin

$100

Lois

Griffin

$150

Joe

Swanson

$300

Cleveland

Brown

$250

水平分规

Document

Firstname

Lastname

Savings

Peter

Griffin

$100

Lois

Griffin

$150

Joe

Swanson

$300

Cleveland

Brown

$250

可悬停表

在上使用:hover选择器来突出显示鼠标经过的表格行

Document

First Name

Last Name

Points

Peter

Griffin

$100

Lois

Griffin

$150

Joe

Swanson

$300

Cleveland

Brown

$250

条纹表

对于斑马条纹表,使用n-child()选择器并为所有偶数(或奇数)表行添加背景颜色

Document

First Name

Last Name

Points

Peter

Griffin

$100

Lois

Griffin

$150

Joe

Swanson

$300

Cleveland

Brown

$250

响应式表格

如果屏幕太小而无法显示全部内容,响应式表格将显示水平滚动条。在

元素周围添加一个带有overflow-x:auto;的容其元素使其响应。在OS X Lion(on Mac)中,滚动条默认使隐藏的,只有使用时才会显示出来,即使设置了overflow:scroll也不行。

Document

First Name

Last Name

Points

Points

Points

Points

Points

Points

Points

Points

Points

Points

Jill

Smith

50

50

50

50

50

50

50

50

50

50

Eve

Jackson

94

94

94

94

94

94

94

94

94

94

Adam

Johnson

67

67

67

67

67

67

67

67

67

67

标签: 拼多多助力网站平台 赚钱项目 拼多多助力网 首码项目 手赚APP
拼多多助力营销技巧