gpt4 book ai didi

HTML:如果按钮的数量超过窗口宽度,我需要将所有按钮保持在同一行。如何解决此行问题?

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

我的元素名称是 Google Module Tab Application。我已经在这个元素中工作了。

这里我面临一个问题。我需要将所有按钮保持在同一行,如果它也超过了窗口宽度。但是在我的元素中,按钮切换并移动到下一行。我该如何解决这个问题

body {
/*padding:100px;*/
}
.limit {
width: 1600px;
overflow: auto;
}
parent {
position: relative;
margin: 20px;
width: 800px;
height: 40px;
}
.button {
position: relative;
/*left:0;*/
display: inline;
width: 200px;
height: 75px;
background-color: lightgray;
font-size: large;
/*border:3px solid #ccc;
margin:0 10px 0;
box-shadow: 0 0 2px #fff inset;*/
-webkit-transform: perspective(100px)rotateX(30deg);
/*-o-transform:rotateX(30deg);
-ms-transform:rotateX(30deg);*/
-moz-transform: perspective(100px)rotateX(30deg);
}
.button:hover {
cursor: default;
}
.button:active {
cursor: move;
z-index: 40;
}
.button.drag {
z-index: 99;
background-color: orange;
}
<div id="parent" class="parent">
<div class="limit">
<button data-tab="tab-1" class="button current ">Car 1</button>
<button data-tab="tab-2" class="button">Car 2</button>
<button data-tab="tab-3" class="button">Car 3</button>
<button data-tab="tab-4" class="button">Car 4</button>
<button data-tab="tab-5" class="button">Car 5</button>
<button data-tab="tab-6" class="button">Computer</button>
<button data-tab="tab-7" class="button">Message</button>
<button data-tab="tab-8" class="button">Nature</button>
<button data-tab="tab-9" class="button">Power</button>
</div>
</div>

The wrong ouput snapshot is attached here

最佳答案

只是使用宽度大小的替代方法 - flex 的用法:

 <style>
body
{
/*padding:100px;*/
}
.limit
{
width:1600px;
display:flex;
flex-wrap:nowrap;
}
parent {
position:relative;
margin: 20px;
width: 800px;
height: 40px;

}
.button {
position:relative;
/*left:0;*/
display: inline-flex;
width: 200px;
height: 75px;
background-color:lightgray;
font-size:large;
/*border:3px solid #ccc;
margin:0 10px 0;
box-shadow: 0 0 2px #fff inset;*/
-webkit-transform: perspective(100px)rotateX(30deg);
/*-o-transform:rotateX(30deg);
-ms-transform:rotateX(30deg);*/
-moz-transform: perspective(100px)rotateX(30deg);
}
.button:hover {
cursor: default;
}
.button:active
{
cursor:move;
z-index:40;
}
.button.drag {
z-index: 99;
background-color:orange;
}

</style>
<body>
<div id="parent" class="parent">
<div class="limit">
<button data-tab="tab-1" class="button current " >Car 1</button>
<button data-tab="tab-2" class="button">Car 2</button>
<button data-tab="tab-3" class="button">Car 3</button>
<button data-tab="tab-4" class="button">Car 4</button>
<button data-tab="tab-5" class="button">Car 5</button>
<button data-tab="tab-6" class="button">Computer</button>
<button data-tab="tab-7" class="button">Message</button>
<button data-tab="tab-8" class="button">Nature</button>
<button data-tab="tab-9" class="button">Power</button>
</div>
</div>

关于HTML:如果按钮的数量超过窗口宽度,我需要将所有按钮保持在同一行。如何解决此行问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40354573/

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