gpt4 book ai didi

html - div中的垂直和水平居中按钮

转载 作者:太空宇宙 更新时间:2023-11-04 11:09:56 24 4
gpt4 key购买 nike

我真的需要你的帮助,

如何修改下面的 HTML 和 CSS 标记,使包含在 Div(“框 D”)中的按钮在垂直和水平方向上居中?

这是有问题的 HTML 和 CSS:

<!DOCTYPE html>

<html>

<head>

<style type="text/css">
* {
font-family: Segoe UI;
font-size: 9pt;
box-sizing: border-box;
}
#main {
border: 1px solid rgb(180,180,180);
width: 800px;
height: 650px;
}
#boxA {
padding-top: 7px;
padding-bottom: 7px;
padding-left: 3px;
border-bottom: 1px solid rgb(180,180,180);
}
#boxB {
height: 573px;
width: 200px;
border: 0;
float: left;
}
#boxC {
background: rgb(240,240,240);
height: 573px;
width: 598px;
border-left: 1px solid rgb(180,180,180);
border-top: 0;
border-bottom: 0;
border-right: 0;
display: inline-block;
}
#boxD {
background: rgb(240,240,240);
border-top: 1px solid rgb(180,180,180);
height: 44px;
text-align: center;
}
#menu {
list-style-type: none;
padding: 0;
margin: 0;
}
#menu li {
padding: 4px;
border: 1px solid #FFF;
}
#menu li:hover {
cursor: pointer;
}
.selected {
background: rgb(51,153,255);
color: #FFF;
border: 1px solid #FFF;
font-weight: bold;
}
.hidden{ display:none; }


.item {
width: 100%;
height: 100%;
}


input[type="button"]
{
cursor:pointer;
border: 1px solid #707070;
background-color: #F0F0F0;
border-radius: 4px;
box-shadow: inset 0 1px 2px #fff, inset 0 -0.7em #DDD;
background-image: -ms-linear-gradient(top, #F1F1F1 0%, #E3E3E3 50%, #D0D0D0 100%);
padding: 3px 6px;
width: 75px;
}

input[type="button"]:hover
{
cursor:pointer;
background-color: #EAF6FD;
border: 1px solid #3C7FB1;
box-shadow: inset 0 1px 2px #fff, inset 0 -0.7em #BEE6FD, 0 0 3px #A7D9F5;
}

input[type="button"][disabled], input[type="button"][disabled]:hover

{
border: 1px solid #ADB2B5;
text-shadow: 1px 1px #fff;
cursor:default;
background-color: #F4F4F4;
box-shadow: inset 0 1px 2px #fff;
}
</style>

<script type="text/javascript">

$(document).ready(function() {

$("#menu li").click(function(){
var $li = $(this);
var selector = $li.data("show");
$('.item').addClass('hidden');

$('ul').children().removeClass('selected');

$(selector).removeClass("hidden");
$(this).addClass("selected");

//alert($(this).attr("class").split(' '))
});

$("#menu li").eq(0).click();

});
</script>

</head>

<body>

<div id="main">

<div id="boxA"><b>Application Title</b></div>

<div id="boxB">
<ul id="menu">
<li data-show="#1">Menu Item 1</li>
<li data-show="#2">Menu Item 2</li>
<li data-show="#3">Menu Item 3</li>
</ul>
</div>


<div id="boxC">

<div id="1" class="hidden item">
<b>Content Tab 1</b>
</div>

<div id="2" class="hidden item">
Content Tab 2
</div>

<div id="3" class="hidden item">
Content Tab 3
</div>

</div>

<div id="boxD">

<div style="display: table-cell; vertical-align: middle;">
<input type="button" value="Search" class="btn" disabled>
<input type="button" value="Save" class="btn" disabled>
<input type="button" value="Add" class="btn" disabled>
<input type="button" value="Clear All" class="btn">
<input type="button" value="Delete" class="btn" disabled>
<input type="button" value="Export" class="btn" disabled>
<input type="button" value="Recall" class="btn" disabled>
</div>

</div>

</div>

</body>

</html>

最佳答案

如果你像这样更新你的#boxD:

#boxD {
display: table;
width: 100%;

示例代码:

$(document).ready(function() {

$("#menu li").click(function(){
var $li = $(this);
var selector = $li.data("show");
$('.item').addClass('hidden');

$('ul').children().removeClass('selected');

$(selector).removeClass("hidden");
$(this).addClass("selected");

//alert($(this).attr("class").split(' '))
});

$("#menu li").eq(0).click();

});
* {
font-family: Segoe UI;
font-size: 9pt;
box-sizing: border-box;
}
#main {
border: 1px solid rgb(180,180,180);
width: 800px;
height: 650px;
}
#boxA {
padding-top: 7px;
padding-bottom: 7px;
padding-left: 3px;
border-bottom: 1px solid rgb(180,180,180);
}
#boxB {
height: 573px;
width: 200px;
border: 0;
float: left;
}
#boxC {
background: rgb(240,240,240);
height: 573px;
width: 598px;
border-left: 1px solid rgb(180,180,180);
border-top: 0;
border-bottom: 0;
border-right: 0;
display: inline-block;
}
#boxD {
display: table;
width: 100%;
background: rgb(240,240,240);
border-top: 1px solid rgb(180,180,180);
height: 44px;
text-align: center;
}
#menu {
list-style-type: none;
padding: 0;
margin: 0;
}
#menu li {
padding: 4px;
border: 1px solid #FFF;
}
#menu li:hover {
cursor: pointer;
}
.selected {
background: rgb(51,153,255);
color: #FFF;
border: 1px solid #FFF;
font-weight: bold;
}
.hidden{ display:none; }


.item {
width: 100%;
height: 100%;
}


input[type="button"]
{
cursor:pointer;
border: 1px solid #707070;
background-color: #F0F0F0;
border-radius: 4px;
box-shadow: inset 0 1px 2px #fff, inset 0 -0.7em #DDD;
background-image: -ms-linear-gradient(top, #F1F1F1 0%, #E3E3E3 50%, #D0D0D0 100%);
padding: 3px 6px;
width: 75px;
}

input[type="button"]:hover
{
cursor:pointer;
background-color: #EAF6FD;
border: 1px solid #3C7FB1;
box-shadow: inset 0 1px 2px #fff, inset 0 -0.7em #BEE6FD, 0 0 3px #A7D9F5;
}

input[type="button"][disabled], input[type="button"][disabled]:hover

{
border: 1px solid #ADB2B5;
text-shadow: 1px 1px #fff;
cursor:default;
background-color: #F4F4F4;
box-shadow: inset 0 1px 2px #fff;
}
<div id="main">

<div id="boxA"><b>Application Title</b></div>

<div id="boxB">
<ul id="menu">
<li data-show="#1">Menu Item 1</li>
<li data-show="#2">Menu Item 2</li>
<li data-show="#3">Menu Item 3</li>
</ul>
</div>


<div id="boxC">

<div id="1" class="hidden item">
<b>Content Tab 1</b>
</div>

<div id="2" class="hidden item">
Content Tab 2
</div>

<div id="3" class="hidden item">
Content Tab 3
</div>

</div>

<div id="boxD">

<div style="display: table-cell; vertical-align: middle;">
<input type="button" value="Search" class="btn" disabled>
<input type="button" value="Save" class="btn" disabled>
<input type="button" value="Add" class="btn" disabled>
<input type="button" value="Clear All" class="btn">
<input type="button" value="Delete" class="btn" disabled>
<input type="button" value="Export" class="btn" disabled>
<input type="button" value="Recall" class="btn" disabled>
</div>

</div>

</div>

关于html - div中的垂直和水平居中按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33700678/

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