Home > Web Front-end > HTML Tutorial > How to center this box_html/css_WEB-ITnose

How to center this box_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:00:27
Original
1512 people have browsed it

怎么让这个框居中呢
css码

@charset "utf-8";
/* CSS Document */

html{height:100%;border:none;}
body{height:100%;border:none;padding:0;margin:0;text-align:center;font-size:14px;color:#000;background-color:#FFF;}
div,ul,li,img{margin:0;padding:0;border:none;}
ul{list-style-type:none;}
table,input{font-size:12px;}
a:link{ color:#09F; text-decoration:none;  }
a:visited{ color:#09F; text-decoration:none;  }
a:hover{ color:#09F; text-decoration:none;  }
a:active{ color:#09F; text-decoration:none;  }

.mass{width:1024px;}
.center{text-align:center;}
.clear{ clear:both;visibility:hidden;font-size:0px;}
.border{ border:#F00 solid 1px;}



html 码




无标题文档




text



回复讨论(解决方案)

自身的居中是margin:0 auto; 
demo here

<!doctype html><html><head>    <meta charset="UTF-8">    <title></title>    <style type="text/css">        html{height:100%;border:none;}        body{height:100%;border:none;padding:0;margin:0;text-align:center;font-size:14px;color:#000;background-color:#FFF;}        div,ul,li,img{margin:0;padding:0;border:none;}        ul{list-style-type:none;}        table,input{font-size:12px;}        a:link{ color:#09F; text-decoration:none;  }        a:visited{ color:#09F; text-decoration:none;  }        a:hover{ color:#09F; text-decoration:none;  }        a:active{ color:#09F; text-decoration:none;  }        .mass{width:1024px;margin: 0 auto;}        .center{text-align:center;}        .clear{ clear:both;visibility:hidden;font-size:0px;}        .border{ border:#F00 solid 1px;}    </style></head><body><div class="border mass">text</div></body></html>
Copy after login
Copy after login
Copy after login

自身的居中是margin:0 auto;
demo here

<!doctype html><html><head>    <meta charset="UTF-8">    <title></title>    <style type="text/css">        html{height:100%;border:none;}        body{height:100%;border:none;padding:0;margin:0;text-align:center;font-size:14px;color:#000;background-color:#FFF;}        div,ul,li,img{margin:0;padding:0;border:none;}        ul{list-style-type:none;}        table,input{font-size:12px;}        a:link{ color:#09F; text-decoration:none;  }        a:visited{ color:#09F; text-decoration:none;  }        a:hover{ color:#09F; text-decoration:none;  }        a:active{ color:#09F; text-decoration:none;  }        .mass{width:1024px;margin: 0 auto;}        .center{text-align:center;}        .clear{ clear:both;visibility:hidden;font-size:0px;}        .border{ border:#F00 solid 1px;}    </style></head><body><div class="border mass">text</div></body></html>
Copy after login
Copy after login
Copy after login



这个左漂 右漂怎么不起作用?

css码

@charset "utf-8";
/* CSS Document */

html{height:100%;border:none;}
body{height:100%;border:none;padding:0;margin:0;text-align:center;font-size:14px;color:#000;background-color:#FFF;}
div,ul,li,img{margin:0;padding:0;border:none;}
ul{list-style-type:none;}
table,input{font-size:12px;}
a:link{ color:#09F; text-decoration:none; }
a:visited{ color:#09F; text-decoration:none; }
a:hover{ color:#09F; text-decoration:none; }
a:active{ color:#09F; text-decoration:none; }

.mass{width:1024px;margin: 0px auto}
.center{text-align:center;}
.clear{ clear:both;visibility:hidden;font-size:0px;}
.border{ border:#F00 solid 1px;}


#nav{}
#nav.left{ float:left;width:226px;}
#nav.right{ float:right;width:501px;}

html码





无标题文档

















The centering of itself is margin: 0 auto;
demo here

<!doctype html><html><head>    <meta charset="UTF-8">    <title></title>    <style type="text/css">        html{height:100%;border:none;}        body{height:100%;border:none;padding:0;margin:0;text-align:center;font-size:14px;color:#000;background-color:#FFF;}        div,ul,li,img{margin:0;padding:0;border:none;}        ul{list-style-type:none;}        table,input{font-size:12px;}        a:link{ color:#09F; text-decoration:none;  }        a:visited{ color:#09F; text-decoration:none;  }        a:hover{ color:#09F; text-decoration:none;  }        a:active{ color:#09F; text-decoration:none;  }        .mass{width:1024px;margin: 0 auto;}        .center{text-align:center;}        .clear{ clear:both;visibility:hidden;font-size:0px;}        .border{ border:#F00 solid 1px;}    </style></head><body><div class="border mass">text</div></body></html>
Copy after login
Copy after login
Copy after login



Why doesn’t this left and right drift work?

css code

@charset "utf-8";
/* CSS Document */

html{height:100%;border:none;}
body{height:100%;border:none;padding:0;margin:0;text-align:center;font-size:14px;color:#000;background-color:#FFF;}
div ,ul,li,img{margin:0;padding:0;border:none;}
ul{list-style-type:none;}
table,input{font-size:12px;}
a:link{ color:#09F; text-decoration:none; }
a:visited{ color:#09F; text-decoration:none; }
a:hover{ color:#09F; text- decoration:none; }
a:active{ color:#09F; text-decoration:none; }

.mass{width:1024px;margin: 0px auto}
.center{text- align:center;}
.clear{ clear:both;visibility:hidden;font-size:0px;}
.border{ border:#F00 solid 1px;}


# nav{}
#nav.left{ float:left;width:226px;}
#nav.right{ float:right;width:501px;}

html code





Untitled Document

















#nav . left{ float:left;width:226px;}
#nav .right{ float:right;width:501px;}
There should be a space in the middle to indicate the subordinate relationship.
Related labels:
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