我真的很難放置一個div標籤。我需要將帶有黃色邊框的表單框放在右邊,我的文本入站行銷和中間的子文本。任何人都可以幫助我解決這個問題嗎?浮動div元素正確
- 文本鋪在帶綠色邊框的div中。
- 背景圖片在div與紅色邊框
這裏鋪設是我的代碼是我的嘗試到現在爲止。 我的代碼如下所示:
HTML:
<div class="top-area" style="border: 4px solid red;">
<div class="container" style="border: 4px solid green;">
<div class="form-container" style="border: 4px solid yellow;">
<div>
@Umbraco.RenderMacro("Ebook")
</div>
</div>
<h1 class="header-xl center">
@Html.Raw(headerText)
</h1>
<p class="sub-header center">
@Html.Raw(CurrentPage.imageTeaserText)
</p>
</div>
</div>
CSS
.top-area {
position: relative;
text-align: center;
}
.top-area, .top-area > .container {
min-height: 500px;
display: -ms-flexbox;
display: flex;
}
.top-area > .container {
-ms-flex-align: center;
align-items:center;
-ms-flex-pack: center;
justify-content: center;
-ms-flex-direction: column;
flex-direction: column;
}
.top-area p {
margin: 0;
color: #fff;
width: 100%;
}
.top-area .header-xl {
margin-top: 20px;
padding: 0;
}
.top-area .sub-header {
font-weight: 300;
margin-top: 5px;
font-size: 2.8em !important;
}
.form-container {
display: block;
float: right;
float: right;
padding: 20px 0;
width: 320px;
}
因爲容器類中的flex屬性,刪除display:flex;它將所有元素與容器的中心對齊。 – Khurram