如何在css中增加一种样式

html-css020

如何在css中增加一种样式,第1张

<div class="Inx_Com_Left">改为 <div>

这里不需要浮动 他自己就会是100%宽度

如果要定为720px宽 又不想友情链接在上面

就在后面清除浮动 即可

光CSS可能实现不了这个问题,若是能实现请说明。我现在说下CSS结合JS实现。

首先我不知道你有在一个页面里有多少个TD,所以我写个通用的方法。希望能给你帮助。

<!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/1888/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8" />

<title>无标题文档</title>

<style>

.td_bg{

background:#CCC

}

.td_down{

background:#f00

}

</style>

<script>

function mousedown(nameId,numId,total){

for(i=0i<=totali++){

document.getElementById(nameId+i).className = 'td_bg'

//alert(nameId+i)

}

document.getElementById(nameId+numId).className = 'td_down'

//alert(nameId+numId)

}

</script>

</head>

<body>

<div id="showdiv" style="background:#CCC"></div>

<table width="200" border="0" cellspacing="1" cellpadding="0">

<tr>

<td id="td0" onclick="mousedown('td',0,8)" class="td_bg"> </td>

<td id="td1" onclick="mousedown('td',1,8)" class="td_bg"> </td>

<td id="td2" onclick="mousedown('td',2,8)" class="td_bg"> </td>

</tr>

<tr>

<td id="td3" onclick="mousedown('td',3,8)" class="td_bg"> </td>

<td id="td4" onclick="mousedown('td',4,8)" class="td_bg"> </td>

<td id="td5" onclick="mousedown('td',5,8)" class="td_bg"> </td>

</tr>

<tr>

<td id="td6" onclick="mousedown('td',6,8)" class="td_bg"> </td>

<td id="td7" onclick="mousedown('td',7,8)" class="td_bg"> </td>

<td id="td8" onclick="mousedown('td',8,8)" class="td_bg"> </td>

</tr>

</table>

</body>

</html>

在css设置可改变大小的div滚动条样式方法:

1.首先新建html文档,进入代码书写界面。

2.在</head>和<body>的里面写入代码,在<div>里面写入想要输入的内容</div>。

3.书写外层轨道css代码。body::-webkit-scrollbar { width:20pxheight:2pxbackground:#cccborder-radius:10px/*外层轨道*/}

这里主要是设置外层轨道的形状和颜色。

4.书写内层轨道css代码。body::-webkit-scrollbar-thumb{ display:blockwidth:6pxmargin:0 autoborder-radius: 10pxbackground:red/*内层轨道*/}

这里主要是设置内层轨道的形状和颜色。

5.代码工作做完后,就可以查看效果,效果如下红框所示,滚动条设置完成。