CSS怎么控制超链接在背景图片居中?

html-css014

CSS怎么控制超链接在背景图片居中?,第1张

可以用css控制

如果单独的图片放置在浏览器中央位置,一般用margin:0 auto

用一个区块包住

<div class="a">

<img src="xxx" />

</div>

.a {

width: xxx

margin: 0 auto

}

我来给你一个完整的文件吧。呵呵。你运行一下,兼容各种浏览器,喜欢的话一定要多加点分哦。

http://hi.baidu.com/fenggandeguozi/blog/item/e675327b051e9fe82f73b37b.html

欢迎到我空间逛逛。

<!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/htmlcharset=GB2312" />

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

<style type="text/css">

.pp-list { height: 1%overflow: hiddendisplay:tableborder-spacing:10px}

.pp-list li {border:1px solid #aaawidth:150pxheight:150pxtext-align:centervertical-align:middleposition:relativemargin: 10px*float:left display: table-cell}

.pp { *position:absolutetop:50%}

.pp img { *position:relativetop:-50%left:-50%}

</style>

</head>

<body>

<ul class="pp-list">

<li><div class="pp"><img src="http://i0.sinaimg.cn/blog/08index/blog_mj_005_2.gif" ></div></li>

<li><div class="pp"><img src="http://mat1.qq.com/www/images/allskin/wmlogo.gif" ></div></li>

<li><div class="pp"><img src="http://img1.cache.netease.com/cnews/netease/logo_w.gif" ></div></li>

</ul>

</body>

</html>

文字的居中嘛,很简单,用“text-align:center”语句就行了。要是需要让Div居中,就用“margin:0 auto;”。0呢,代表上下间距为零;auto在这里的意思就是左右间距自适,可以实现居中的效果。

还有链接字体的颜色,因为一般要用到a标记,所以要实现改变所有链接文字的颜色的话,加一句

“a{color:#颜色值;}”就成了,这样链接文字的颜色就改变了。

e.g: a{color:#ccc} a:hover{color:#000} (hover表示鼠标经过状态)