gpt4 book ai didi

html - 如果我先将鼠标悬停在某个单词上,CSS Hover 只会在页面上起作用。为什么?

转载 作者:太空宇宙 更新时间:2023-11-04 05:16:00 26 4
gpt4 key购买 nike

我页面的许多功能(文本)包括 css 悬停和事件。

但是

只有当我首先将鼠标悬停在某个似乎触发其他词的词上时,它们才会起作用。

这是为什么?

在我的例子中,#input1 有一个活跃的部分,当点击边框时会改变颜色。但这将不起作用,直到我将光标悬停在页脚文本上。

谢谢!

詹姆斯

这是 html:

<html>
<head>
<link href="cloud.css" rel="stylesheet" type="text/css" />

</head>
<body>


<div class="center1"style="margin-top: 300px;">
<form>
<input type="text" class="input1" autofocus="autofocus">
<input type="text" class="input2">
</div>


<div class="footer" style="position:absolute;bottom:0;">
<div class="footer1">

&nbsp;&nbsp;&nbsp;<div id="footer1text">
<a href="aboutus.html " style="text-decoration:none;">About Us</a></div>
&nbsp;&nbsp;&nbsp;<div id="footer1text">Accessibility</div>
&nbsp;&nbsp;&nbsp;<div id="footer1text">Recruiters</div>
&nbsp;&nbsp;&nbsp;<div id="footer1text">Contact Us</div>
</div>
<div class="footer2">
&nbsp;&nbsp;&nbsp;<div id="footer2textcopyright">&copy; 2011 -</div>
<div id="footer2text">Privacy</div>&nbsp;&nbsp;&nbsp;

</div>
</div>


</body>
</html>

CSS:

 body {
margin: 0;
padding: 0;
}

input:focus {
outline: none;
}

.center div {
display:inline-block;
}

.center {
text-align:center;
width:100%px;
margin:0 auto;
}

.center1 div {
display:inline-block;
}

.center1 {
text-align:left;
width:1200px;
text-align:center;
width:100%px;
margin:0 auto;
}

.footer {
background: #FFFFFF;
border-top: 1px solid;
color: #e6e6e6;
height: 30px;
width: 100%;
position:absolute;
float: left;
margin: 0px 0px 0px 0px;
padding:0;
display: table;
}

.footer1 {
background: #FFFFFF;
height: 30px;
width: 350px;
float: left;
margin: 0px 0px 0px 0px;
padding:0;
display:table;
}

#footer1text2 {
font: 13px helvetica;
color: #0040FF;
display: table-cell;
}



.clickhere {
font: 13px helvetica;
color: #0040FF;
text-decoration: underline;
}

#footer1text2:hover {
font: 13px helvetica;
color: #0040FF;
text-decoration: underline;
}

#footer1text {
font: 13px helvetica;
color: #0040FF;
padding: 8px 3px 3px 3px;
display: table-cell;
}

#footer1text:hover {
font: 13px helvetica;
color: #0040FF;
padding: 8px 3px 3px 3px;
text-decoration: underline;
}

.footer2 {
background: #FFFFFF;
height: 30px;
width: 130px;
float: right;
margin: 0px 0px 0px 0px;
padding:0;
display:table;
}

#footer2text {
font: 13px helvetica;
color: #0040FF;
padding: 8px 3px 3px 3px;
display: table-cell;
text-align: right;
}

#footer2text:hover {
font: 13px helvetica;
color: #0040FF;
padding: 8px 3px 3px 3px;
text-decoration: underline;
}

#footer2textcopyright {
font: 13px helvetica;
color: #151515;
padding: 8px 3px 3px 3px;
display: table-cell;
text-align: right;
}

.input1 {
height: 40px;
width: 280px;
background: #FFFFFF;
border: 1px solid #bdbdbd;
border-top: 1px solid #A4A4A4;
font: 21px HelveticaNeue-Light;
color: #151515;
text-align: left;
}

.input1:active {
height: 40px;
width: 280px;
background: #FFFFFF;
border: 1px solid #e6e6e6;
border-top: 1px solid #A4A4A4;
font: 21px HelveticaNeue-Light;
color: #151515;
text-align: left;
}

.input2 {
height: 40px;
width: 280px;
background: #FFFFFF;
border: 1px solid #bdbdbd;
border-top: 1px solid #A4A4A4;
font: 21px HelveticaNeue-Light;
color: #151515;
text-align: left;
}

最佳答案

您期望 input1:active.input1:focus 一样工作

改变:

.input1:active {
height: 40px;
width: 280px;
background: #FFFFFF;
border: 1px solid #e6e6e6;
border-top: 1px solid #A4A4A4;
font: 21px HelveticaNeue-Light;
color: #151515;
text-align: left;
}

到:

.input1:focus {
outline: none;
height: 40px;
width: 280px;
background: #FFFFFF;
border: 1px solid #e6e6e6;
border-top: 1px solid #A4A4A4;
font: 21px HelveticaNeue-Light;
color: #151515;
text-align: left;
}

附言

修正你的代码,你需要关闭那个表单标签,并且应该对你的输入做同样的事情。代码中的样式声明之间也应该有一个空格

<div class="center1" style="margin-top: 300px;">  <!-- added space between class and style declarations -->
<form>
<input type="text" class="input1" autofocus="autofocus" /> <!-- close with slash -->
<input type="text" class="input2" /> <!-- close with slash -->
</form> <!-- close the form -->
</div>

关于html - 如果我先将鼠标悬停在某个单词上,CSS Hover 只会在页面上起作用。为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8080174/

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