打印

[讨论] CSS布局实验题一(检验CSS布局灵活性)

如果在li里加入div,就违背了原题的意思了。

好厉害! 学到了处理ul和li来显示边框的妙招!


 提示:您可以先修改部分代码再运行
火狐 IE7 效果是一样的了。。。

OPERA有点出入。。。

我的方法

<!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=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body {
       margin: 0px;
       padding: 0px;
}
#list{
       width:400px;
       margin-top: 0px;
       margin-right: auto;
       margin-bottom: 0px;
       margin-left: auto;
}
#list ul {
       list-style-type: none;
       margin: 0px;
       padding: 0px;
}
#list li {
       display: block;
       float: left;
       text-align: center;
       width: 100px;
       margin-top: 0px;
       margin-right: auto;
       margin-bottom: 0px;
       margin-left: auto;
       height: 40px;
       border: 1px solid #FFFFFF;
       background-color: #6699CC;
       color: #FFFFFF;
       font-size: 12px;
       line-height: 40px;
}
-->
</style>
</head>
<body>
<div id="list">
<ul>
<li>1</li><li>2</li><li>3</li>
<li>4</li><li>5</li><li>6</li>
</ul>
</div>
</body>
</html>

TOP

引用:
原帖由 wobuup 于 2007-6-26 20:59 发表
为什么不能整体距中呢??

明明有
margin:0 auto;
要 margin:0px auto;

TOP

还在为头像烦恼?还在为不能关注好友动态烦忧?快来蓝色理想家园吧!
哈哈,我看了理解了一下楼主的意思!!
表格布局内容多的时候可以自由伸缩但是CSS布局的就不太好做了!!
就单单限制在这些内容中!!
可以看看按这些代码吗?

 提示:您可以先修改部分代码再运行
[ 本帖最后由 wlx115 于 2007-9-12 15:48 编辑 ]

TOP

17楼的数字不居中啊,而list中的center命令好像没用啊,大家能解释一下为什么吗?还有怎么把div中的内容的坐标搞定?
成长进步中

TOP

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
#list{width:50%;margin:0 auto;}
#list ul{width:100%;margin:0;padding:0;list-style:none;border:2.5px #00CC33 solid;}
<!--去掉#list ul{width:100%}  ul 自适应宽/高度-->
#list li{width:30%;height:100px;line-height:100px;text-align:center;float:left;background-color:#FFFFCC;border:2.5px #00CC33 solid;}
-->
</style>
</head>
<body>
<div id="list">
<ul>
<li>1</li><li>2</li><li>3</li>
<li>4</li><li>5</li><li>6</li>
</ul>
</div>
</body>
</html>


高手在哪里?~~?~~~?~~

TOP

是不是觉得很闲啊

TOP

#23 在FF里边显示错误怎么修改呢?

TOP

唉,我都不知道看到多少类似的帖子了,真不懂这些人怎么这么爱钻牛角尖,现在大家所说的用DIV布局,并不是希望你们抛弃TABLE,“物尽其用各司其责”,这才是我们因该提倡的,何必那么较真呢?

TOP

引用:
原帖由 wobuup 于 2007-6-26 20:59 发表
为什么不能整体距中呢??

明明有
margin:0 auto;



[html] 1列固定宽度


#layout {

margin:0 auto;
  background-color:#cccccc;
border:2px solid # 333333;
width:300;
height:300;

...
在你的style里添加下面代码,就可以了.

body{
text-align:center;
}

TOP

你要验证的两点都是对的.DIV+CSS很多人都做到了.
只是你举的例子,对这两点有些不容易做到.至少表现不明显.

TOP

复制内容到剪贴板
代码:
<!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">
ul{
margin:0px;
padding:0px;
}
#list{
width:50%;
margin:0 auto;
height:215px;
}
#list li{
list-style:none;
display:block;
float:left;
width:32%;
height:100px;
background-color:#FFFFCC;
text-align:center;
line-height:100px;
border:solid 5px #00CC33;
}
#list li.left{
border-left-width:0px;
}
#list li.right{
border-right-width:0px;
}
#list li.bottom{
border-bottom-width:0px;
}
</style>
</head>
<body>
<div id="list">
<ul>
<li class="right">1</li>
<li>2</li>
<li class="left">3</li>
<li class="right">4</li>
<li>5</li>
<li class="left">6</li>
</ul>
</div>
</body>
</html>

TOP

回复 badwish 在 4# 的帖子

4楼写的帅~
以另一种方式~ PFPF。

TOP

good

TOP

引用:
原帖由 wobuup 于 2007-6-26 20:59 发表
为什么不能整体距中呢??

明明有
margin:0 auto;



[html] 1列固定宽度


#layout {

margin:0 auto;
  background-color:#cccccc;
border:2px solid # 333333;
width:300;
height:300;

...
应该是需要对文档进行声明。!DOCTYPE

TOP



 提示:您可以先修改部分代码再运行

TOP

回复 wobuup 在 30# 的帖子

<style>
ul{width:490px;margin:0;padding:0;list-style:none;}
ul li{height:100px;line-height:100px;text-align:
center;float:left;width:150px;background:#FFFFCC;
border:solid 5px #00CC33;}

ul #li_12{
border-right:solid 0px #00CC33;
border-bottom:solid 0px #00CC33;}
ul #li_3{width:155px;
border-bottom:solid 0px #00CC33;}
ul #li_45{
border-right:solid 0px #00CC33;
}
ul #li_6{width:155px;
}
</style>
<div style="text-align:
center;">
<ul>
<li id="li_12">1</li><li id="li_12">2</li><li

id="li_3">3</li>
<li id="li_45">4</li><li id="li_45">5</li><li

id="li_6">6</li>
</ul>
</div>

TOP

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<!-- 调用样式表 -->
<style type="text/css">
<!--
#list{margin:0 auto;padding:0px;border:0;width:491px;height:225px;font-size:16px;font-weight:normal; }
#list ul{float:left;margin:0;padding:0 0;border:0px;width:491px;height:217px;list-style:none;background-color:#00CC33;}
#list li{display:inline;float:left;width:157px;height:101px;background-color:#FFFFCC;padding:0px;border:0;margin:5px 0 0 5px;text-align:center;line-height:101px;}
-->
</style>
</head>
<body>
<div id="list">
<ul>
<li>1</li><li>2</li><li>3</li>
<li>4</li><li>5</li><li>6</li>
</ul>
</div>
</body>

TOP

完全实现了楼主所要求的,不需要动到hTML,纯cSS实现

TOP

感觉有点不同

TOP