![](/img/trans.png)
[英]How to place two divs besides each other? first div contain a form, second div contain google map
[英]How to display a 2 x 2 grid with div 1 and div 2 on top of each other in the first column, and div 3 in the second column spawing two rows
以下代碼
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>TITLE</title>
<style>
.a-block {
background-color: #000066;
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-template-rows: repeat(2, 1fr);
padding: 10px;
gap:10px;
}
.a-block > div {
background-color: #FF0000;
border: 1px solid rgba(255, 255, 255, 0.8);
padding: 50px;
gap: 10px;
}
.c_title {
display:grid;
grid-area: 1 / 1 / 2 / 2
font-size: 2em;
text-align: left;
background-color: #FF0000;
gap: 10px;
}
.c_body {
display:grid;
grid-area: 2 / 1 / 3 / 2
font-size: 1.5em;
text-align: justify;
font-size: calc(1.5em + (1vw - 0.5em)); /* adapt font-size based on screen size */
min-font-size: 0.8em; /* minimum font-size */
background-color: #0000FF;
gap: 10px;
}
.p_img {
display:grid;
grid-area: 1 / 2 / 3 / 3
background-color: #FF0000;
gap: 10px;
}
.p_img > img {
object-fit: cover;
width: 100%;
max-height: 100%;
}
}
</style>
</head>
<body>
<div class="a-block" >
<div class="c_title">title</div>
<div class="c_body">
Lorem ipsum dolor sit
</div>
<div class="p_img" >
<img src="https://icatcare.org/app/uploads/2018/07/Thinking-of-getting-a-cat.png" >
</div>
</div>
<p></p>
</body>
</html>
產生這個結果
我希望在第一列中相互堆疊的兩個 div 都在第一行。 我希望在第二列中生成兩行的圖像是第二行和第一行
查看 Chrome 的檢查器,我可以看到我的網格布局信息以某種方式被忽略了,但我沒有找到解決方法
我嘗試了許多關於網格布局和屬性的變體,但它一直被忽略。
.a-block { background-color: #000066; display: grid; grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); padding: 10px; gap:10px; }.a-block > div { background-color: #FF0000; border: 1px solid rgba(255, 255, 255, 0.8); padding: 50px; gap: 10px; }.c_title { font-size: 2em; text-align: left; background-color: #FF0000; gap: 10px; }.c_body { font-size: 1.5em; text-align: justify; font-size: calc(1.5em + (1vw - 0.5em)); /* adapt font-size based on screen size */ min-font-size: 0.8em; /* minimum font-size */ background-color: #0000FF; gap: 10px; }.p_img { grid-area: 1 / 2 / span 2 / 2; background-color: #FF0000; gap: 10px; }.p_img > img { object-fit: cover; width: 100%; max-height: 100%; }
<div class="a-block" > <div class="c_title">title</div> <div class="c_body"> Lorem ipsum dolor sit </div> <div class="p_img" > <img src="https://icatcare.org/app/uploads/2018/07/Thinking-of-getting-a-cat.png" > </div> </div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.