帮我优化一段CSS代码.
解决时间 2021-07-18 22:34
- 提问者网友:饥饿走向夜
- 2021-07-18 13:19
google广告代码的center能不能用css代替!还有那些我觉得无用css id呀 ss cc 标签能不能合并掉!让CSS标准一些。
还有貌似那些div的位置也不标准。高手把他优化一下!保持页面原样就好。
------------------------- 这是网页 --------------------
<!DOCTYPE html>
<html lang="zh-CN">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>测试</title>
<style type="text/css">
@charset "UTF-8";
html, body {font: normal 12px "Lucida Grande",Tahoma,Verdana,Lucida,Arial,Helvetica,sans-serif,"宋体";}a, a:link, a:visited, a:active { color: #333; text-decoration: underline; }a:hover { color: #000; text-decoration: underline; }img, a img { color: #fff; vertical-align: middle; }#main{position: relative;margin-top:50px;margin-left:auto;margin-right:auto;width:700px; padding:0 0 0 0;}#frame{position: relative;padding:0 0 0 0;width:600px;margin:0 0 0 0;}#left{ position: relative;padding:0 0 0 0;float:left;width:400px;margin:0 0 0 0;}#add{position: relative;padding:0 0 0 0;float:right;width:200px;margin:0 0 0 0;font-size:20px;}#ss{height:50px;}hr{color:#F1EDF0;}h2 {font-size:28px;font-weight:bold;background:#f0f0f0;margin:0 0 20px 0;}h3 {font-size:28px;font-weight:bold;color:#333333;margin:0 0 10px 0;}.thread {padding:0 0 0 0;color: #000000;font-weight: bold;border-bottom: 1px solid #eee;margin-bottom: 9px;}#cc {clear:both;}#copyright {position: relative;padding:0 0 0 0;text-align:right;width: 580px;}
</style>
</head>
<body>
<div id="main">
<div id="frame">
<div id="left">
<div class="thread"><h3>留言</h3></div>
<p>说明…… </p>
<p> 感谢您使用……</p>
<p>评论</p>
<form method="post" action="">
<textarea rows="5" cols="40"></textarea><p>
<input type="submit" name="submit" value="提交" /></p>
</form>
</div>
<div id="ss"></div>
<div id="add">
<center>
<script type="text/javascript"><!--
google_ad_client = "pub-4860885871900357";
google_ad_slot = "9541324742";
google_ad_width = 120;
google_ad_height = 240;
//-->
</script>
<script type="text/javascript"
src=" http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</center>
</div>
<div id="cc"></div>
<div id="copyright"><div class="thread"></div>©2009 XXX </div>
</div>
</div>
最佳答案
- 五星知识达人网友:举杯邀酒敬孤独
- 2021-07-18 14:22
我不太清楚你所希望到达的效果是怎样的,你所说的那个SS CC是可以去掉的,没什么影响。
我不是高手,所以总感觉这样页面好看些:把id为thread的颜色改为灰色,DIV浮动的位置很正确,
<!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>
<title>测试</title>
<style type="text/css">
charset "UTF-8";
html, body
{
font: normal 12px "Lucida Grande",Tahoma,Verdana,Lucida,Arial,Helvetica,sans-serif,"宋体";
}
a, a:link, a:visited, a:active
{
color: #333; text-decoration: underline;
}
a:hover
{
color: #000; text-decoration: underline;
}
img, a img
{
color: #fff; vertical-align: middle;
}
#main
{
position: relative;margin-top:50px;margin-left:auto;margin-right:auto;width:700px; padding:0 0 0 0;
}
#frame
{
position: relative;padding:0 0 0 0;width:600px;margin:0 0 0 0;
}
#left
{
position: relative;padding:0 0 0 0;float:left;width:400px;margin:0 0 0 0;
}
#add
{
position: relative;padding:0 0 0 0;float:right;width:200px;margin:0 0 0 0;font-size:20px;
}
hr
{
color:#F1EDF0;
}
h2
{
font-size:28px;font-weight:bold;background:#f0f0f0;margin:0 0 20px 0;
}
h3
{
font-size:28px;font-weight:bold;color:#333333;margin:0 0 10px 0;
}
.thread
{
padding:0 0 0 0;color: #000000;font-weight: bold;border-bottom: 1px solid gray;margin-bottom: 9px;
}
#copyright
{
position: relative;padding:0 0 0 0;text-align:right;width: 580px;
}
</style>
</head>
<body>
<div id="main">
<div id="frame">
<div id="left">
<div class="thread"><h3>留言</h3></div>
<p>说明…… </p>
<p> 感谢您使用……</p>
<p>评论</p>
<form method="post" action="">
<textarea rows="5" cols="40"></textarea><p>
<input type="submit" name="submit" value="提交" /></p>
</form>
</div>
<div id="add">
<center>
<script type="text/javascript"><!--
google_ad_client = "pub-4860885871900357";
google_ad_slot = "9541324742";
google_ad_width = 120;
google_ad_height = 240;
//-->
</script>
<script type="text/javascript" src=" http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</center>
</div>
<div id="copyright"><div class="thread"></div>©2009 XXX </div>
</div>
</div>
</body>
</html>
全部回答
- 1楼网友:轻熟杀无赦
- 2021-07-18 16:36
<!DOCTYPE html>
<html lang="zh-CN">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>测试</title>
<style type="text/css">
@charset "UTF-8";
html, body {font: normal 12px "Lucida Grande",Tahoma,Verdana,Lucida,Arial,Helvetica,sans-serif,"宋体";}
a,a:link,a:visited,a:active {color: #333; text-decoration: underline;}
a:hover {color:#000; text-decoration: underline;}
img,a img {color:#fff; vertical-align: middle;}
#main {margin:50px auto 0;width:700px;}
#frame {width:600px;}
#left {float:left;width:400px;}
#add {float:right;width:200px;font-size:20px;}
#ss {height:50px;}
hr {color:#f1edf0;}
#main,#frame,#left,#add,#copyright {position:relative;}
.thread {color:#000;border-bottom:1px solid #eee;margin-bottom:9px;}
h2,h3,.thread {font-weight:bold;}
h2 {font-size:28px;background:#f0f0f0;margin:0 0 20px 0;}
h3 {font-size:28px;color:#333;margin:0 0 10px 0;}
#cc {clear:both;}
#copyright {text-align:right;width:580px;}
</style>
</head>
<body>
<div id="main">
<div id="frame">
<div id="left">
<div class="thread">
<h3>留言</h3>
</div>
<p>说明…… </p>
<p>感谢您使用……</p>
<p>评论</p>
<form method="post" action="">
<textarea rows="5" cols="40"></textarea><p>
<input type="submit" name="submit" value="提交" /></p>
</form>
</div>
<div id="ss"></div>
<div id="add">
<center>
<script type="text/javascript"><!--
google_ad_client = "pub-4860885871900357";
google_ad_slot = "9541324742";
google_ad_width = 120;
google_ad_height = 240;
//-->
</script>
<script type="text/javascript"
src=" http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</center>
</div>
<div id="cc"></div>
<div id="copyright"><div class="thread"></div>©2009 XXX </div>
</div>
</div>
觉得哪里不好可以继续追问。
优化内容:1、主要合并不同内容的相同属性。
2、代码美观性进行了优化。
- 2楼网友:长青诗
- 2021-07-18 15:45
<!DOCTYPE html>
<html lang="zh-CN">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>测试</title>
<style type="text/css">
@charset "UTF-8";
html, body {font: normal 12px "Lucida Grande",Tahoma,Verdana,Arial,,"宋体";}
a, a:link, a:visited, a:active { color: #333; text-decoration: underline; }
a:hover { color: #000; text-decoration: underline; }
img, a img { color: #fff; vertical-align: middle; }
#main,#frame,#left,#add,#copyright {position: relative;padding:0 0 0 0;margin:0 0 0 0;}
#main{margin-top:50px;margin-left:auto;margin-right:auto;width:700px; }
#frame{width:600px;}
#left{ float:left;width:400px;}
#add{float:right;width:200px;font-size:20px;}
#ss{height:50px;}hr{color:#F1EDF0;}
h2 {font-size:28px;font-weight:bold;background:#f0f0f0;margin:0 0 20px 0;}
h3 {font-size:28px;font-weight:bold;color:#333333;margin:0 0 10px 0;}
.thread {padding:0 0 0 0;color: #000000;font-weight: bold;border-bottom: 1px solid #eee;margin-bottom: 9px;}
#cc {clear:both;}
#copyright {text-align:right;width: 580px;}
</style>
</head>
<body>
<div id="main">
<div id="frame">
<div id="left">
<div class="thread"><h3>留言</h3></div>
<p>说明…… </p>
<p> 感谢您使用……</p>
<p>评论</p>
<form method="post" action="">
<textarea rows="5" cols="40"></textarea><p>
<input type="submit" name="submit" value="提交" /></p>
</form>
</div>
<div id="add">
<center>
<script type="text/javascript"><!--
google_ad_client = "pub-4860885871900357";
google_ad_slot = "9541324742";
google_ad_width = 120;
google_ad_height = 240;
//-->
</script>
<script type="text/javascript"
src=" http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</center>
</div>
<div id="cc"></div>
<div id="copyright"><div class="thread"></div>©2009 XXX </div>
</div>
</div>
--------------------------------------------------------------------------------------------
就是把相同部分合并一下,剩下都是需要的
- 3楼网友:神也偏爱
- 2021-07-18 15:16
这样写吧,简化部分不必要的标签
<!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">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>测试</title>
<style type="text/css">
html, body {
font: normal 12px "Lucida Grande",Tahoma,Verdana,Lucida,Arial,Helvetica,sans-serif,"宋体";
line-height: 150%;
}
h1,h5,p,form{
padding: 0;
margin: 0;
}
a,
a:link,
a:visited,
a:active {
color: #333;
text-decoration: underline;
}
a:hover {
color: #000;
text-decoration: underline;
}
#main{
margin: 50px auto;
width: 500px;
}
#main h1{
padding: 5px 0 5px 0;
font-size: 20px;
border-bottom: 1px solid #ccc;
}
.content{
margin: 10px 0 10px 0;
}
.content h5{
padding: 5px 0 5px 0;
font-size: 14px;
}
.content p{
text-indent: 2em;
}
#copyright{
margin-top: 10px;
padding-top: 5px;
text-align: right;
border-top: 1px solid #ccc;
}
form textarea{
height: 80px;
width: 100%;
}
form input{
margin: 5px 0 5px 0;
}
</style>
</head>
<body>
<div id="main">
<h1>留言</h1>
<div class="content">
<h5>说明</h5>
<p>感谢您使用……</p>
</div>
<div>评论:</div>
<form method="post" action="">
<textarea></textarea>
<input type="submit" name="submit" value="提交" />
</form>
<div id="copyright">©2009 XXX </div>
</div>
</body>
</html>
我要举报
大家都在看
推荐资讯