关于css里<li>内文字 竖直居中 ?

html-css015

关于css里<li>内文字 竖直居中 ?,第1张

1.首先,打开HTML编辑器并创建一个新的HTML文件,比如index。说明:html,用于填写代码的基本层次的问题。-

2.在index.html中的<style>标签中,将“.shoucang .sc_ul li”中的“height: 73px”调整为:height: 73pxpadding-top: 7px。

3.最后,浏览器运行index.html页面,发现li标记中的文本垂直和水平居中。

扩展资料:

其他代码:

Thecodeisasfollows:

<style type = "text/CSS" >

.Shoucang{

Width:58px;

Height:300px;

Float:correct;

Background-color:#CCC;

Border:1pxentity#999;

.Shoucang.Sc_ul{

Width:21px;

Margin-right:car;

Margin-left:car;

Thelist-style-type:no;

Padding-top:20px;

Padding-right:0px;

Padding-bottom:0px;

Padding-left:0px;

Margin-top:0px;

Margin-bottom:0px;

.Shoucang.Sc_ulli{

Thetext-align:center;

Vertical-align:intermediate;

Height:80px;

Width:21px;

Margin-bottom:9px;

Color:#FFF.

Textmodification:no;

Thetext-align:center;

Vertical-align:intermediate;

Background-color:#FF0000;

Fontsize:12px;

Border:1pxentity#666;

-->

></ style

</ a >

The <body >

<div class = "shoucang" >

<ul class = "sc_ul" ><li >set as home </ li ><li >lee </ >

<li class = "no" >contact way lee </ a >

</ ul >

需要准备的材料分别有:电脑、html编辑器、浏览器。

1、首先,打开html编辑器,新建一个html文件,例如:index.html,填充问题基础代码。

2、在index.html中的<style>标签中,将“.shoucang .sc_ul li”中的“height: 73px”调整为:height: 73pxpadding-top: 7px。

3、最后,浏览器运行index.html页面,此时发现li标签中的文字被垂直和水平居中了。

1、利用定位,先给父元素加一个定位属性,比如position:relative,然后给想要居中的元素设置

{

    position: absolute

    top: 0

    right: 0

    bottom: 0

    top: 0

    margin: auto

}//这个是上下左右全部居中,如果只是上下垂直居中,可以只设置top和bottom为0,

//left和right根据需要设置一个即可,这个适用于一些不方便计算上下距离的情况

//对于指导上下距离的可以直接使用top,left定位即可

2、vertical-align:middle;属性,该属性是让元素位于父元素的中部。

3、也可以使用css3属性来移动元素,让元素居中

4、或者使用padding值之类的属性来使元素上下垂直居中或者横向居中都可以