请教一个关于css居中的问题_html/css_WEB-ITnose

WBOY
Release: 2016-06-21 09:44:00
Original
1511 people have browsed it

CSS 居中


-----------------------
使用以上内容时,css是左对齐的,怎么样才能居中啊?

回复讨论(解决方案)

text-align: center;text-decoration: none;background: #EAEBD8;color: #2875DE;font: 16px 宋体,arial;}/*字体*/#sddm div a:hover{ background: #49A3FF;color: #FFF}
Copy after login

意思是在text-decoration: none;前面加入text-align: center;吗?

谢谢veryhunger,请问是改成这样吗?改了没效果。
-----------
#sddm
{ margin: 0 auto;
padding: 0;
z-index: 30;
background-color:#F4F4F4;
width: 100%;
height:23px;}

#sddm li
{ margin: 0;
padding: 0;
list-style: none;
float: left;
font: bold 16px 宋体}

#sddm li a
{ display: block;
margin: 0 1px 0 0;
padding: 4px 10px;
width: 100px;/*宽度*/
background: #5970B2;
color: #FFF;
text-align: center;
text-decoration: none}

#sddm li a:hover
{ background: #49A3FF}

#sddm div
{ position: absolute;
visibility: hidden;
margin: 0;
/*padding: 0;*/
background: #EAEBD8;
border: 1px solid #5970B2}

#sddm div a
{ position: relative;
display: block;
margin: 0;
padding: 5px 10px;
width: auto;
white-space: nowrap;
text-align: left;
text-align: center;
text-decoration: none;
background: #EAEBD8;
color: #2875DE;
font: 16px 宋体,arial;}/*字体*/

#sddm div a:hover
{ background: #49A3FF;
color: #FFF}

--------

没有dom结构没法看

HTML代码贴出来撒! 一般都是固定宽度居中布局吧。width:500px; margin:0px auto; 这个就能居中

没有dom结构没法看
------------------------
代码如下:
nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



网站首页




代码见楼上,本来是回ly12530的。呵呵,请各位大神们指导一下,才开始学习,好多不懂。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template