gpt4 book ai didi

html FORM 标签搞乱了我的 css 内联显示

转载 作者:行者123 更新时间:2023-11-27 23:50:30 25 4
gpt4 key购买 nike

当我添加 <form>标记在我的 HTML 中,它会扰乱我表单的“内联”显示。

有效的 HTML:

<div class="header">
<a href="index.html"> <img src="icon.png" width="45"></a>
<div class="headertitle">TITLE</div>

<select class="form-field">
<option>test</option>
</select>

<select class="form-field" >
<option>test2</option>
</select>

<div class="headermenu">test3</div>

<select class="form-field" >
<option>test4</option>
</select>

<div class="headermenu">test5</div>
</div>

如果我添加 <form>它不起作用...请参阅 html 代码:

<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post" name="form1">    
<select class="form-field">
<option>test</option>
</select>

<select class="form-field" >
<option>test2</option>
</select>

<div class="headermenu">test3</div>

<select class="form-field" >
<option>test4</option>
</select>

</form>

查看工作图像和非工作图像....

这是我的 CSS:

.header{width: 100%; background-color: #5e6172;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
align-items: center; /* vertical align */
justify-content: center; /* horizontal align */
position: fixed;
top:0;
height: 80px;
}

.headertitle{color: #ffffff; font-size: 1.7em; font-family: h35; margin: 0 0.5%;
font-weight:bold; display: inline-block;}

.headermenu{color: #ffffff; font-size: 1.4em; font-family: h35; margin: 0 0.3%;
display: inline-block;}

.form-field {background: #fff; color: #5e6172; padding:4px; font-family: h35;
font-size: 1.2em; margin: 0 0.4%; }

.form-field:focus {background: #e0dedf; color: #725129; }

enter image description here

enter image description here

最佳答案

可以在form中添加display: inline-flex来固定容器的宽度:

FIDDLE

关于html FORM 标签搞乱了我的 css 内联显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27682606/

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