所以我有兩個帶有超鏈接的圖像,當我嘗試將它們居中時,它們的行爲很有趣,所以我認爲它可能是元素的尺寸被扭曲了?不知何故?所以我添加邊框的元素四周,果然,他們的尺寸是這樣的:HTML + CSS - 使用超鏈接對圖像進行定位
https://gyazo.com/f5a91e1a26eaf3aea6208ffa2eea698c
HTML:
<a id="home-invite-button" href="https://url.com" target="_blank"><img
src="Images/Invite Button.png"></a>
<a id="home-wiki-button" href="https://url.com" target="_blank"><img
src="Images/Wiki Button.png"></a>
CSS:
#home-invite-button {
position: absolute;
top: 540px;
left: 0px;
right: 0px;
margin: 0px auto;
width: 50%;
border: thin black solid;
}
#home-wiki-button {
position: absolute;
top: 630px;
left: 0px;
right: 0px;
margin: 0px auto;
width: 50%;
border: thin black solid;
}
所以問題是,我怎樣才能使元素的實際大小與實際圖像相同?非常感謝!
非常感謝,這工作!我還了解到寬度的東西實際上並不是要走的路。總的來說,很棒的回答:) –
這是我的榮幸。如果你覺得這個答案有用,也請注意它。 –
hehe是啊我需要15代表第一:P –