パディングを持つ親divの下にあるボタンを使用してdivを配置しようとしています。パディングを無視した絶対配置
期待される結果は、パディング(緑色領域)の上にボタン休止を有しています。
.btn-default,
.btn-default:hover,
.btn-default:focus {
color: #333;
text-shadow: none;
/* Prevent inheritence from `body` */
background-color: #fff;
border: 1px solid #fff;
}
a,
a:focus,
a:hover {
color: #fff;
}
body {
background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.6)), url("../img/blank.jpg");
background-attachment: fixed;
background-size: cover;
background-repeat: no-repeat;
background-position: center top;
}
html,
body {
height: 100%;
}
body {
color: #fff;
text-align: left;
text-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}
#mcontainer {
position: relative;
float: left;
padding: 10%;
width: 100%;
height: 100%;
}
#header h1 {
margin: 0px;
}
#header {
height: auto;
}
#footer .link-item a {
display: table-cell;
padding: 10px 10px;
border: 2px solid white;
}
#footer {
position: absolute;
top: auto;
bottom: 0%;
height: auto;
}
#footer .link-item:first-child {
border-spacing: 0px 10px;
margin: 10px 10px 10px 0px;
}
#footer .link-item {
border-spacing: 0px 10px;
margin: 10px 10px;
}
<!DOCTYPE html>
<html lang="en">
<body>
<div id="mcontainer">
<div id="header">
<h1>Text</h1>
</div>
<div id="footer">
<span class="link-item"><a href="www.google.com" target="new">Button</a> </span>
<span class="link-item"><a href="www.google.com" target="new">Button</a> </span>
<span class="link-item"><a href="www.google.com" target="new">Button</a> </span>
<span class="link-item"><a href="www.google.com" target="new">Button</a> </span>
<span class="link-item"><a href="www.google.com" target="new">Button</a> </span>
</div>
</div>
</body>
</html>
任意の助けいただければ幸いです。
を_ "期待される結果が上のボタンの休憩をしています(緑色の領域)。 "_ - あなたの期待は間違っています。絶対配置では、埋め込みが考慮されません。あなたの要素が持つパディングの量を知っているなら、あなたの 'bottom'の位置にその値を使用してください。 – Turnip
Ok cool。それは私の疑惑を確認します。私が望むものを達成するためのベストプラクティスはありますか?「フッタ」の底を確認する必要はありませんか? 私の目標は、ページの真ん中にテキストを、下にボタンを置いてコンテナを置くことです。私はパディングが行く方法だったという印象を受けました。 –
@Turnipの提案に完全に不満があります。 inbox.google.comとそのサイドナビゲーションをご覧ください。 Absolute for DIVのためにパディングが追加されていますが、Firefoxでは動作しません –