gpt4 book ai didi

html - CSS 初学者,帮助创建此布局?

转载 作者:太空宇宙 更新时间:2023-11-03 20:38:19 25 4
gpt4 key购买 nike

在下图中,左边是我的 html/css 的输出,右边是我希望布局的样子。

我对以下问题一无所知:

  • 如何使标题居中
  • 为什么标题将“右上”文本和按钮强制到下一行(而不是在右上方向)
  • 如何对齐文本区域,使其位于图像的右侧

<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="outer_border">
<div class="inner_border">
<!--just use a div to represent the image -->
<div class ="image">
</div>
<span class="upper_left_text">
upper left
</span>
<span class ="header">
<h2>
Header
</h2>
</span>
<span class="upper_right_text">
upper right
</span>
<button class="button1">Button</button>
<textarea class="text_area">Text Area</textarea>
<button class="button2">Button 2</button>
</div>
</div>
</body>
</html>

.outer_border {
border: 1px solid black;
width: 600px;
height: 500px;
}

.inner_border {
border: 3px solid black;
width: 400px;
height: 300px;
float: right;
}

.image {
border: 1px solid black;
display: inline-block;
width: 50px;
height: 100px;
margin: 5px;
float: left;
}



.the_header {
text-align: center;
display: inline-block;
}

.button1 {
float: right;
}

.button2 {
float: right;
width: 80px;
height: 60px;
}

.text_area {
clear: both;
display: block;
width: 100%;
height: 150px;
margin: 5px;
/*I have no idea how to position this*/
}

.upper_left_text {
float: left;
}

.upper_right_text {
float: right;
}

enter image description here

最佳答案

我做了一个 jsfiddle,检查这个,应该让你开始:)

https://jsfiddle.net/fazbyxyq/

html5

<div class="right">
<div>upper left</div>
<div>header</div>
<div>upper right</div>
<div><textarea>textarea</textarea></div>
<div>button2</div>
</div>

CSS3

*{
box-sizing:border-box;
-moz-box-sizing:border-box;
}

.left{
float:left;
width:10%;
height:100px;
border:1px solid #000;
}

.right{
float:left;
width:89%;
margin-left:1%;
}

.right div{
float:left;
width:33%;
border:1px solid #000;
}

.right div:nth-child(2){
text-align:center;
}

.right div:nth-child(3){
text-align:right;
}

.right div:nth-child(4),.right div:nth-child(5){
width:99%;
border:0;
}

.right div:nth-child(4) textarea{
width:100%;
height:100px;
margin:10px 0;
}

.right div:nth-child(5){
text-align:right;
}

安静下来!

关于html - CSS 初学者,帮助创建此布局?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29870299/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com