我正在嘗試製作一個簡單的頁面,其中有3個div,1是頂部div,代表頁眉, 其他2個與其他2個小間隔相鄰。到目前爲止好,這是我的代碼看起來像:需要使用div內的按鈕解決方案
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div id="main">
<div class="head">GIMP & Inscape galerija</div>
<div class="content"><button>Test</button></div>
<div class="outcome">Here is the outcome, that will come, when i will press buttons</div>
</div>
</body>
</html>
和CSS
body {
background-image: url("../img/background.jpg");
background-repeat: no-repeat;
}
#main {
width: 1400px;
margin: 0 auto;
position: relative;
}
.head {
width: 1400px;
height: 100px;
margin: 0 auto;
border: solid 1px;
border-radius: 25px;
text-align: center;
line-height: normal;
display: flex;
justify-content:center;
align-content:center;
flex-direction:column;
margin-top: 50px;
}
.content {
width: 350px;
margin: 0 auto;
height: 600px;
border: solid 1px;
margin: 35px 0px 0px 0px;
border-radius: 10px;
display: inline-block;
}
.outcome {
width: 991px;
height: 600px;
border: solid 1px;
margin: 0 auto;
margin-left:50px;
border-radius: 10px;
display: inline-block;
}
之前我添加任何按鍵,這沒關係,一切都在行理所應當是。當我添加按鈕時,我的結果div向下移動,並且它發生在我嘗試的每個按鈕上。如果有人能告訴我,那會有什麼不好,也可能會在代碼中發現一些錯誤。
對不起,我不完全理解這個問題。所以你想要所有3個塊在一個單一的行? (添加按鈕之前和之後) – leocreatini
繼續操作,將您擁有的代碼添加到Codepen或SO的代碼編輯器中。 我只是將它自己添加到Codepen,我無法複製您遇到的問題,所以我希望可以。 –
我添加了一個小提琴來玩弄任何感興趣的代碼。 https://jsfiddle.net/px2mw1ck/不能真正看到問題出在哪裏?將寬度更改爲%數量,但剩下的數量與原來一樣。對我來說它看起來很好。 – deadfishli