下面是一个测试文件,test.htm
,这与这导致在Firefox:将锚标签大小设置为其div内容?
的<div>
为绿色,带黄色边框和指定大小,以及<a>
与红色边框。显然,锚标签具有更大的宽度和高度,它包含的div。我怎样才能使锚标签大小等于其div内容 - 但是,以这种方式,<div>
的大小和位置不变?基本上,对于该示例和示出的浏览器窗口大小,我想这个(手动编辑的PIC):
test.htm
:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style type="text/css">
body {
padding:0;
margin:0;
width: 100%;
height: 100%;
background-color: white;
color: darkred;
}
div#button {
margin-top: 2vh;
padding: 2em;
width: 20em;
border-style: solid;
border-width: 2px;
border-color: yellow;
background-color: lightgreen;
text-align: center;
font-size: 3vh;
/* to center div horizontally: */
margin-left: auto;
margin-right: auto;
}
a {
text-decoration: none; /*remove underline of a href link:*/
display: block;
width: auto;
padding: 0;
margin: 0;
color: unset;
border-style: solid;
border-width: 2px;
border-color: red;
}
</style>
</head>
<body>
<br/>
<a href="test.zip" target="_blank"><div id="button">Download this</div></a>
</body>
</html>
取决于它是如何被使用的,你可以将它设置为'显示。 –