gpt4 book ai didi

html - 无法让表单元素排成一行并且响应迅速?

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

我试图将表单元素保持在一行中,并且对于所有类型的分辨率都以这种方式保持它完全一样,即保持它在相同状态下响应,但每当我尝试最小化屏幕分辨率时,表单内容搞砸了,搜索按钮转到第二行,因为我不希望它变成那样。我只是希望它处于相同的状态,即即使在窗口打开时,搜索按钮也保持在输入旁边被最小化了那么容易实现吗???据我所知,它可以通过使用 CSS 媒体查询来实现......!

这是 GIF:enter image description here

实时页面链接: http://huntedhunter.com/extratorrent/

代码如下:

HTML :

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div style="padding: 7%;margin-top: 100px;">
<h1>E<span>XTRATORRENT</span> A<span>UTOMATIC</span> D<span>OWNLOADER</span></h1>
<form>
<input class="icon" name="search" placeholder="Search Torrent Name" type="text"> <input class="btn btn-secondary" name="search" type="submit" value="Search">
</form>
</div>
<footer class="footer">
<p>Copyrighted By <strong><a href="http://www.huntedhunter.com">Hunted Hunter Solutions</a></strong>.A Script By <a href="http://stackoverflow.com/users/2298933/umair-shah-yousafzai?tab=profile"><strong>Umair Shah Yousafzai</strong></a></p>
</footer>
</body>
</html>

CSS:

input[type=text].icon {
width: 89%;
padding: 12px 20px;
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
font-size: 16px;
background-color: white;
background-image: url(searchicon.png);
background-position: 10px 13px;
background-repeat: no-repeat;
padding-left: 42px;
}

h1 {
font-family: Arial;
opacity: 0.6;
text-align: center;
}
span {
font-size: 70%;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
background-color: #eee2e2;
margin-left: -0.5%;
}

body {
overflow-x: hidden;
}

p {
text-align: center;
font-family: Arial;
opacity: 0.7;
}
a {
text-decoration: none;
}

.btn-secondary:hover {
color: #292b2c;
background-color: #e6e6e6;
border-color: #adadad;
cursor: pointer;
}
.btn:focus, .btn:hover {
text-decoration: none;
}
[type=reset], [type=submit], button, html [type=button] {
-webkit-appearance: button;
}
.btn-secondary {
color: #292b2c;
background-color: #fff;
border-color: #adadad;
}
.btn {
border: 1px solid turquoise;
padding: 1.2% 1.5rem;
font-size: 1rem;
border-radius: .25rem;
-webkit-transition: all .2s ease-in-out;
-o-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
}

最佳答案

你可以使用 flex-box为此。

添加 .flex给你上课 <form>标记以及规则:

.flex {
display:flex;
flex-wrap:nowrap;
justify-content:center;
}

替换width: 89%;flex-grow:4;input[type=text].icon 上选择器,

最后加上flex-grow:1;margin-left:5px;.btn选择器

input[type=text].icon {
flex-grow: 4;
padding: 12px 20px;
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
font-size: 16px;
background-color: white;
background-image: url(searchicon.png);
background-position: 10px 13px;
background-repeat: no-repeat;
padding-left: 42px;
}

h1 {
font-family: Arial;
opacity: 0.6;
text-align: center;
}

span {
font-size: 70%;
}

.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
background-color: #eee2e2;
margin-left: -0.5%;
}

body {
overflow-x: hidden;
}

p {
text-align: center;
font-family: Arial;
opacity: 0.7;
}

a {
text-decoration: none;
}

.btn-secondary:hover {
color: #292b2c;
background-color: #e6e6e6;
border-color: #adadad;
cursor: pointer;
}

.btn:focus,
.btn:hover {
text-decoration: none;
}

[type=reset],
[type=submit],
button,
html [type=button] {
-webkit-appearance: button;
}

.btn-secondary {
color: #292b2c;
background-color: #fff;
border-color: #adadad;
}

.btn {
flex-grow: 1;
margin-left: 5px;
border: 1px solid turquoise;
padding: 1.2% 1.5rem;
font-size: 1rem;
border-radius: .25rem;
-webkit-transition: all .2s ease-in-out;
-o-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
}

.flex {
display: flex;
flex-wrap: nowrap;
justify-content: center;
}
<!DOCTYPE html>
<html>

<head>
<title></title>
</head>

<body>
<div style="padding: 7%;margin-top: 100px;">
<h1>E<span>XTRATORRENT</span> A<span>UTOMATIC</span> D<span>OWNLOADER</span></h1>
<form class="flex">
<input class="icon" name="search" placeholder="Search Torrent Name" type="text" /> <input class="btn btn-secondary" name="search" type="submit" value="Search" />
</form>
</div>
<footer class="footer">
<p>Provided without garanties by a <strong><a href="http://www.thefreedictionary.com/welldoer">Welldoer</a></strong>. A Script By <a href="http://stackoverflow.com/users/1203738/lars"><strong>Lars</strong></a></p>
</footer>
</body>

</html>

关于html - 无法让表单元素排成一行并且响应迅速?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42630226/

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