请教一个关于css居中的问题_html/css_WEB-ITnose
CSS 居中
-----------------------
使用以上内容时,css是左对齐的,怎么样才能居中啊?
回复讨论(解决方案)
text-align: center;text-decoration: none;background: #EAEBD8;color: #2875DE;font: 16px 宋体,arial;}/*字体*/#sddm div a:hover{ background: #49A3FF;color: #FFF}
意思是在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的。呵呵,请各位大神们指导一下,才开始学习,好多不懂。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...

To achieve the effect of scattering and enlarging the surrounding images after clicking on the image, many web designs need to achieve an interactive effect: click on a certain image to make the surrounding...

The Y-axis position adaptive algorithm for web annotation function This article will explore how to implement annotation functions similar to Word documents, especially how to deal with the interval between annotations...

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.
