整合营销服务商

电脑端+手机端+微信端=数据同步管理

免费咨询热线:

HTML中行级标签和块级标签的转化

HTML中行级标签和块级标签的转化

、行级标签转换为块级标签

转换为块级标签,各自独占一行,且可以设置宽高

代码:<a href="">我是a标签</a>

<a href="">我是a标签</a>

<a href="">我是a标签</a>

CSS :display:block;

width: 100px;

height: 30px;

border: 1px solid black;

在浏览器中的样式:

二、块级标签转换为行级标签

转化为行级标签,共同占一行,不能设置宽高

代码:<h3>我是块级标签</h3>

<h3>我是块级标签</h3>

<h3>我是块级标签</h3>

CSS:display: inline;

width: 200px;

height: 100px;

border: 1px solid red;

在浏览器中的样式:

三、转化为行内块级标签

能共占一行,而且可以设置各自的宽高

1.行级元素转化为行内块级元素

代码:<a class="a1" href="">我是a标签</a>

<a class="a2" href="">我是a标签</a>

CSS: a{ display:inline-block; border: 1px solid black; }

.a1{width: 100px; height: 30px; }

.a2{ width: 50px; height: 50px; }

在浏览器中的样式:

2.块级标签转化为行内块级标签

代码:<h3 class="h3_1">我是块级标签</h3>

<h3 class="h3_2">我是块级标签</h3>

CSS:h3{display: inline-block;border: 1px solid red;}

.h3_1{width: 100px;height: 100px;}

.h3_2{width: 200px;height: 50px;}

在浏览器中的样式:

四、display的另一个属性,可以将元素隐藏

display:none;

如果想了解更多块级标签和行内标签的属性,请关注,参看上一篇文章,有写的不对或不全面的地方,请大家多多指出。

本属性

字体了解之后,接下来我们了解一下文本属性。缩进、角标、间距、排版等。

text-decoration

文本装饰

描述
none默认。定义标准的文本。
underline定义文本下的一条线。
overline定义文本上的一条线。
line-through定义穿过文本下的一条线。
blink定义闪烁的文本。
inherit规定应该从父元素继承 text-decoration 属性的值。

text-transform

描述
none默认。定义带有小写字母和大写字母的标准的文本。
capitalize文本中的每个单词以大写字母开头。(仅针对首字母)
uppercase定义仅有大写字母。
lowercase定义无大写字母,仅有小写字母。
inherit规定应该从父元素继承 text-transform 属性的值。

text-indent

文本缩进,设置文本的起点,一般我们进行首行缩进。

1
p{text-indent: 2em;}

tip:这个玩意也会继承。

example

1
2
3
4
5
6
7
8
9
10
11
<style type="text/css">
 .box{text-indent: 2em;width: 400px;border: 1px solid #333;}
</style>
<body>
 <div class="box">
 一个很重要的问题一个很重要的问题一个很重要的问题一个很重要的问题一个很重要的问题一个很重要的问题一个很重要的问题一个很重要的问题
 <p>一个很重要的问题一个很重要的问题一个很重要的问题一个很重要的问题一个很重要的问题一个很重要的问题一个很重要的问题一个很重要的问题</p>
 <p>一个很重要的问题一个很重要的问题一个很重要的问题一个很重要的问题一个很重要的问题一个很重要的问题一个很重要的问题一个很重要的问题</p>
 <p>一个很重要的问题一个很重要的问题一个很重要的问题一个很重要的问题一个很重要的问题一个很重要的问题一个很重要的问题一个很重要的问题</p>
 </div>
</body>

text-algin

文本对齐方式

描述
left把文本排列到左边。默认值:由浏览器决定。
right把文本排列到右边。
center把文本排列到中间。
justify实现两端对齐文本效果

letter-spacing

字符间距

这个貌似也没啥说的还是过了吧。。。?乛?乛?

word-spacing

单词间距,亲啊一定要区分清楚啊。 Hi girl!我只能说很少用,毕竟我们不写英文。

line-height

行高,数字。

在css里边最tm难理解的两个东西它就是其中一个。尴尬…

先来个图!

  • green:top(顶线)

  • blue:middle(中线)

  • red:baseline(基线)

  • pink:bottom(底线)

example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<style>
 /*
 	设置字体我们可以同时设置行高,意思就是可以采用数字 2的含义是基于字体大小的倍数
 	通常我们不会这样子写,因为会设置字体的大小,如果是浏览器默认的值当然可以这样子写。
 */
 /*
 	css中行高平均分布在一行文本的上下。
 	这里字体的默认大小是16px,line-height为2那么就是32px,多出来的	
 	16px怎么会在文本的上下各填充8px。但是这样子好像有点... 直接line-height: 32px多好费劲 ⊙︿⊙.
 */
 .p{width: 200px;height: 32px;text-align: center;line-height: 2;border: 1px solid red;}
</style>
<body>
 <p>行高,没错就是我</p>
</body>

vertical-align

垂直对齐 以基线为参照上下移动文本,但是这个玩意只能影响行内元素

在css里边最tm难理解的另一个。

example

1
2
3
4
5
6
<style>
	p sub{font-size:60%; vertical-align:-.4em;}
</style>
<body>
	<p>H<sub>2</sub>O. 10<sup>5</sup></p> 
</body>

tip:vertical-align通常用来让两个行内元素对齐,虽然我们有时候设置了大小行高,行内的元素有时候也无发正常居中毕竟line-height是对文字的。这里line-height与vertical-align大家知道怎么去使用碰到问题解决问题,不要深究,会死

last

最后给大家看一下字体与文本的结合,英文的排版样式布局。欣赏一下!

@import url(http://fonts.googleapis.com/css?family=Pinyon+Script);
*{margin: 0;padding: 0;}
body{
 font-family:"CrimsonRoman", georgia, times, serif;
 background-color:#fff;
 margin:100px 10% 0;
}
/* 设置h2的字体 文本*/
h2{
 font-size:18px;
 line-height:24px;
 font-weight:bold;
 text-align:center;
 font-variant:small-caps;
 word-spacing:.5em;
 letter-spacing:.6em;
}
/* 设置h1的字体 文本 */
h1{
 font-size: 60px;
 line-height:96px;
 font-family:"Pinyon Script", cursive;
 margin:4px 0 -4px;
 text-align:center;
 font-weight:normal;
}
p {
 font-size:18px;
 line-height:24px;
}
/* 设置长引用的边距 */
blockquote {margin:0px 20%;}
/* 设置引用字体的样式 */
q {
 font-size:18px;
 font-style:italic;
 line-height:24px;
}
/* 首字母下沉 */
h1 + p::first-letter {
 font-family:times, serif;
 font-size:90px;
 float:left;
 	line-height:.65;
 padding:.085em 3px 0 0;
}
/* 修改第一行的文本 小型大写字母 */
h1 + p::first-line {
 font-variant:small-caps;
 letter-spacing:.15em;
}
/*只缩进跟在段落后面的段落*/
p + p {text-indent:14px;}
/*引用内容前面的引号*/
q::before {content:"\201C"}
/*引用内容后面的引号*/
q::after {content:"\201D"}
1
2
3
4
5
6
7
8
9
10
11
<!-- q标签 文本两端插入引号 -->
<!-- blockquote标签 标记长引用 会给元素的前后添加边距 -->
<h2>an excerpt from</h2>
<h1>The Hound of the Baskervilles</h1>
<p>Holmes stretched out his hand for the manuscript and flattened it upon his knee. &ldquo;You will observe, Watson, the alternative use of the long s and the short. It is one of several indications which enabled me to fix the date.&rdquo; At the head was written: &ldquo;Baskerville Hall,&rdquo; and below in large, scrawling figures: &ldquo;1742.&rdquo;</p>
<p>&ldquo;It appears to be a statement of some sort.&rdquo;</p>
<p>&ldquo;Yes&mdash;it is a statement of a certain legend which runs in the Baskerville family.&rdquo;</p>
<blockquote>
 <q>Of the origin of the Hound of the Baskervilles there have been many statements, yet as I come in a direct line from Hugo Baskerville, and as I had the story from my father&hellip;</q>
</blockquote>
<p>When Dr. Mortimer had finished reading this singular narrative he pushed his sp

Q&A

1
2
3
4
5
6
7
8
9
10
11
<input type="button" value="按钮">
<input type="button" value="按钮">
<input type="button" value="按钮">
<button>6</button>
<button>6</button>
<button>6</button>
<div style="border: 1px solid #333;width:300px;">
 <img src="url" width="300">
</div>

发现问题了吗? 行内元素在换行显示之后回车被html解析了。

国工商银行、中国农业银行、中国银行和中国建设银行于2019年9月11日至9月15日同时办理中华人民共和国成立70周年双色铜合金纪念币两批次的预约业务。公众可通过上述四家银行业金融机构官方网站或前往其营业网点进行预约登记。

中国银行负责天津、山西、福建、湖北、湖南、广西、重庆、陕西等地区;

如果你不在上面地区,请点击下面相应银行进行预约。

中国农业银行负责江苏、安徽、江西、山东、海南、贵州、西藏、青海、新疆等地区;

中国工商银行负责上海、内蒙古、辽宁、吉林、广东(含深圳市)、四川等地区;

中国建设银行负责北京、河北、黑龙江、浙江、河南、云南、甘肃、宁夏等地区。

中华人民共和国成立70周年双色铜合金纪念币每人预约、兑换限额为20枚

中华人民共和国成立70周年双色铜合金纪念币第一批次于2019年9月19日至9月23日办理预约兑换第二批次于2019年10月25日至10月30日办理预约兑换。公众可按照约定的时间,持在预约系统中登记的有效身份证件,前往约定的营业网点办理预约兑换业务。

中行新中国成立70周年纪念币微信预约入口

注:入口要预约开始时才开放,未到时间会显示“暂无可预约的产品”。

中行新中国成立70周年纪念币网站预约入口

中行可直接复制以下网址:https://cmcoins.boc.cn/BOC15_CoinSeller/welcome.html