Table of Contents
回复讨论(解决方案)
Home Web Front-end HTML Tutorial css格式问题_html/css_WEB-ITnose

css格式问题_html/css_WEB-ITnose

Jun 21, 2016 am 09:20 AM

1

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><style type="text/css">#class3{    width:900px;    margin-left:auto;   margin-right:auto;  position:relative;  background-color:#099;  margin-top:150px;   }#class3 ul{    width:800px;    height:30px;    background-color:#936;  margin-left:auto;   margin-right:auto;  position:relative;  }   #class3 li{ list-style-type: none;  width: 100px;   position:relative;  margin-top:10px;    float:left; background-color:#3F0;  margin-right:10px;  text-align:center;  }   #class2{    width:900px;    margin-left:auto;   margin-right:auto;  position:relative;  background-color:#099;  height:50px;    }           #class2 li .01{ list-style-type: none;  position: absolute; left: 670px;    top: 23px;} .02{    list-style-type: none;  position: absolute; left: 365px;    top: 30px;}.03{ list-style-type: none;  position: absolute; left: 308px;    top: 30px;}.04{ list-style-type: none;  position: absolute; left: -232px;   top: 30px;  }   .05{    list-style-type: none;  position: absolute; left: 201px;    top: 30px;}.06{ list-style-type: none;  position: absolute; left: 252px;    top: 30px;}.07{ list-style-type: none;  position: absolute; left: -97px;    top: 28px;}</style></head><body><div id="class2"><ul><li class="01">横排</li><li class="02">横排</li><li class="03">横排</li><li class="04">横排</li><li class="05">横排</li><li class="06">横排</li><li class="07">横排</li></ul></div><div id="class3"><ul><li>横排</li><li>横排</li><li>横排</li><li>横排</li><li>横排</li><li>横排</li><li>横排</li></ul></div></body></html>

Copy after login


1

.07{    list-style-type: none;  position: absolute; left: -97px;    top: 28px;}

Copy after login

IE8浏览器为什么设置了类中的位置会无效,还是原来那样

1

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><style type="text/css">#box06 {    position:relative;    width: 500px;    height: 100px;  top:50%;  left:50%;  margin-left:-250px;  margin-top:-50px;    background-color:#F39;}  #box07 {    position:absolute;    width: 300px;    height: 30px;    background-color:#0F0;    left:50%;  top:50%;  margin-left:-150px;  margin-top:-15px;}  #box08 {    position:absolute;    width: 300px;    height: 30px;    background-color:#0Ff;    left:30px;  top:50%;}.nav{ width:500px;    background-color:#000;}.nav li{width:80px;float:left;list-style:none;display:inline;background:#0F0;text-align:center;margin-right:10px;}</style></head><body><div class="nav"><ul><li>横排</li><li>横排</li><li>横排</li></ul></div><div> DIV1 </div><div> DIV2 </div><div style= "display:inline "> DIV1 </div><div style= "display:inline "> DIV2 </div><span>DIVCSS!</span> <span>DIVCSS5 </span> <span style= "display:block "> SPAN1 </span><span style= "display:block "> SPAN2 </span><div id="box06">  <div id="box07">box07</div>  <div id="box08">box08</div></div></body></html>

Copy after login


1

.nav{   width:500px;    background-color:#000;}

Copy after login


2、为什么类nav的这个黑色背景色出不来?


回复讨论(解决方案)

1class不要数字开头
2清除float

1

<div class="nav"><ul><li>横排</li><li>横排</li><li>横排</li> </ul>  <div style="clear:both;"></div></div>

Copy after login

1

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><style type="text/css">#class3{    width:900px;    margin-left:auto;   margin-right:auto;  position:relative;  background-color:#099;  margin-top:150px;   }#class3 ul{    width:800px;    height:30px;    background-color:#936;  margin-left:auto;   margin-right:auto;  position:relative;  }   #class3 li{ list-style-type: none;  width: 100px;   position:relative;  margin-top:10px;    float:left; background-color:#3F0;  margin-right:10px;  text-align:center;  }   #class2{    width:100px;    margin-left:auto;   margin-right:auto;  position:relative;  background-color:#099;  height:50px;    }           #class2 .c01{   list-style-type: none;  position: absolute; left: 422px;    top: 15px;  width: 60px;}   .c02{   list-style-type: none;  position: absolute; left: 365px;    top: 15px;  width: 60px;}.c03{  list-style-type: none;  position: absolute; left: 82px; bottom: 0px;    right: 99px;    top: 15px;  height: 31px;   width: 58px;    top: 15px;}.c04{    list-style-type: none;  position: absolute; left: -232px;   top: 30px;  top: 15px;  }   .c05{   list-style-type: none;  position: absolute; left: 162px;    top: 15px;  width: 60px;    height: 32px;}.c06{ list-style-type: none;  position: absolute; left: 252px;    top: 15px;  width: 60px;}.c07{  list-style-type: none;  position: absolute; left: -97px;    top: 15px;  width: 60px;}</style></head><body><div id="class2"><ul><li class="c01">横1排</li><li class="c02">横2排</li><li class="c03">横3排</li><li class="c04">横4排</li><li class="c05">横5排</li><li class="c06">横6排</li><li class="c07">横7排</li></ul></div><div id="class3"><ul><li>横排</li><li>横排</li><li>横排</li><li>横排</li><li>横排</li><li>横排</li><li>横排</li></ul></div></body></html>

Copy after login

1

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><style type="text/css">#box06 {    position:relative;    width: 500px;    height: 100px;  top:50%;  left:50%;  margin-left:-250px;  margin-top:-50px;    background-color:#F39;}  #box07 {    position:absolute;    width: 300px;    height: 30px;    background-color:#0F0;    left:50%;  top:50%;  margin-left:-150px;  margin-top:-15px;}  #box08 {    position:absolute;    width: 300px;    height: 30px;    background-color:#0Ff;    left:30px;  top:50%;}.nav{ width:500px;    background-color:#000;}.nav li{width:80px;float:left;list-style:none;display:inline;background:#0F0;text-align:center;margin-right:10px;}</style></head><body><div class="nav"><ul><li>横排</li><li>横排</li><li>横排</li></ul> <div style="clear:both;"></div></div><div> DIV1 </div><div> DIV2 </div><div style= "display:inline "> DIV1 </div><div style= "display:inline "> DIV2 </div><span>DIVCSS!</span> <span>DIVCSS5 </span> <span style= "display:block "> SPAN1 </span><span style= "display:block "> SPAN2 </span><div id="box06">  <div id="box07">box07</div>  <div id="box08">box08</div></div></body></html>

Copy after login

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1655
14
PHP Tutorial
1253
29
C# Tutorial
1227
24
Is HTML easy to learn for beginners? Is HTML easy to learn for beginners? Apr 07, 2025 am 12:11 AM

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.

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

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

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

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.

What is an example of a starting tag in HTML? What is an example of a starting tag in HTML? Apr 06, 2025 am 12:04 AM

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

How to use CSS3 and JavaScript to achieve the effect of scattering and enlarging the surrounding pictures after clicking? How to use CSS3 and JavaScript to achieve the effect of scattering and enlarging the surrounding pictures after clicking? Apr 05, 2025 am 06:15 AM

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...

HTML, CSS, and JavaScript: Essential Tools for Web Developers HTML, CSS, and JavaScript: Essential Tools for Web Developers Apr 09, 2025 am 12:12 AM

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.

HTML: The Structure, CSS: The Style, JavaScript: The Behavior HTML: The Structure, CSS: The Style, JavaScript: The Behavior Apr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The Future of HTML: Evolution and Trends in Web Design The Future of HTML: Evolution and Trends in Web Design Apr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

See all articles