所以我有这个 Div 对它有滚动效果,它在滚动时改变边框颜色,为了使这个 div 成为一个链接,我把一个链接放到 DIV 中并给它一个 Display: Block属性,以便它填充 div。
我非常困难的是让文本与此 div 的左下角对齐,同时保持阻塞,以便整个翻转区域保持链接。
对于此问题的任何解决方案,我将不胜感激,感谢您的提前帮助,我已经为此奋斗了一段时间。
http://www.klossal.com/media/index_test.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>
<title>MEDIA</title>
</head>
<SCRIPT TYPE="text/javascript">
<!--
function mouseover()
{
document.getElementById("thediv").style.borderLeft="10px solid black";
}
function mouseout()
{
document.getElementById("thediv").style.borderLeft="10px solid #898787";
}
//-->
</SCRIPT>
<style type="text/css">
</style>
</HEAD>
<link rel="shortcut icon" href="\favicon.ico">
<body>
<DIV style="width:200px;height:200px;border-left:10px solid #898787" id=thediv
onmouseover="mouseover()" onmouseout="mouseout()">
<a style="padding-top:1cmpx;" href="www.klossal.com">LINK IT BABY</a>
<DIV>
</body>
</html>
</body>
最佳答案
要将某些内容与底部对齐,可以将 position
设置为 absolute
并将 bottom
设置为 0px
。这会将它对齐到第一个父级的底部,该父级定位为绝对或相对。
在你的例子中,将 DIV
的 position
设置为 relative
,链接的 position
absolute
和 bottom
到 0px
的链接:
http://jsfiddle.net/rodin/jxyZz/
顺便说一句,你可以用纯CSS实现翻转效果,看fiddle。如果你想让整个盒子成为一个链接,盒子应该是一个A
,文本应该是一个DIV
(你反过来做了)。
关于css - 移动显示 :Block link text to the bottom of a div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8733648/