【问题标题】:Select element not working properly with CSS grid选择元素无法与 CSS 网格一起正常工作
【发布时间】:2021-11-29 20:02:53
【问题描述】:

标题。我已经设法使用网格并排对齐 2 个 div,这很好,但是一旦第二个 div 的内容是一个选择元素,第二个 div 出于某种原因更短,我该如何解决?

CSS

.inputwrap{
    display: grid;
    grid-template-areas: 'halfl halfr';
    grid-column-gap: 2%;
}
.input50r{
    grid-area: halfr;
    display:  grid;
}
.input50l{
    grid-area: halfl;
    display:  grid;
}

HTML

<div class='input50l'>
  <input type='password' name='encKey' placeholder='Password' />
</div>
<div class='input50r'>
  <select>
    <option>Option</option>
    <option>Option</option>
  </select>
</div>

problem example

select 元素没有特殊的样式,只是装饰性的

【问题讨论】:

    标签: html css select grid


    【解决方案1】:
    .inputwrap{
        display: grid;
        grid-template-areas: 'halfl halfr';
        grid-column-gap: 2%;
        grid-template-columns: 1fr 1fr;
    }
    

    【讨论】:

    • 那行得通。你能解释一下为什么吗?为什么选择元素行为不端?
    • 我不知道为什么,但我怀疑一切都在使用基于内容的宽度,除非你强制它
    猜你喜欢
    • 2016-11-27
    • 2013-08-10
    • 2012-01-31
    • 1970-01-01
    • 2014-11-01
    • 2017-11-11
    • 1970-01-01
    • 2021-05-22
    • 1970-01-01
    相关资源
    最近更新 更多