gpt4 book ai didi

Android 样式表单 - 我对样式标签有疑问

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

我已经尝试为我和几个伙伴正在进行的元素创建 android 风格的表单。

我已经设法让文本输入字段在我想要的时候改变样式。但我无法让相关标签改变颜色。

这就是我要做的:

enter image description here

您能看到标题和底线是如何变成粉红色的吗?

<html>
<head>
<title>Experementing</title>
<style type="text/css">
@import url(http://fonts.googleapis.com/css?family=Roboto);
body,html
{
font-family: 'Roboto', sans-serif;
}

label
{
font-size: 10px;
color:grey;
}
label:focus
{
color:pink;
}
input
{
border-left: none;
border-top: none;
border-right: none;
border-bottom: solid grey 1px;
color:black;
width:150px;
height:auto;
background: rgba(0,0,0,0);
}
/*Changes style when input box is clicked*/

input:focus, textarea:focus, isindex:focus, keygen:focus, select:focus
{

border-left: none;
border-top: none;
border-right: none;
border-bottom: solid pink 2px;
outline: none;
}
:focus
{
color:pink;
}

/*removes the glow from auto form fill*/
input:-webkit-autofill
{
-webkit-box-shadow:0 0 0 50px white inset; /* Change the color to your own background color */
-webkit-text-fill-color: #333;
}

input:-webkit-autofill:focus
{
-webkit-box-shadow: /*your box-shadow*/,0 0 0 50px white inset;
-webkit-text-fill-color: #333;
}
</style>
</head>
<body>
<form>
<div style="float:left;">
<label for="username">Username<br/>
<input type="text" name="Name" id="username"/></label>
</div>

<div style="float:left; margin-left:10px;">
<label for="pass">Password</label><br/>
<input type="password" name="Nickname" id="pass"/>
</div>
<input type="submit" value="" name="login" style="background: url(sent.svg); border:none; background-size: cover cover; width:25px; height:25px;" />
</form>
</body>
</html>

最佳答案

把你的 <label>在你的 <input> 之后然后使用 CSS 兄弟选择器 ~ .然后你需要移动<label>视觉上回到上方 <input>top:-4em; .

jsFiddle:http://jsfiddle.net/c37eA/

截图:http://i.imgur.com/S3NDLcz.png

如果您不想更改输入颜色(例如,您希望“Blah”为黑色而不是粉红色),请删除规则:

:focus
{
color:pink;
}

关于Android 样式表单 - 我对样式标签有疑问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25108644/

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