- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
于是做了一个小网站,发现了一个问题。我在导航中有两个 ul 标签,我在其中放置了几个 li 标签,然后在其中一些 li 标签中放置了一些 ul 标签,我还在另一个 li 的其中一个 li 标签中放置了一个 img。然后,当我应用一些动画时,img 会与其他选项卡一起移动……这里有一些图片;
When nothing is touched with the mouse. Everything looks fine
But when I'm dragging this down the lock img is following down.
这是整个导航栏的代码:
body{
margin-left: 10px;
padding: 10px;
font-family: arial;
background-color: #E9EBEE !important;
}
nav {
margin-top: -10px;
height: 80px;
background-color: #2A3943;
padding: 5px;
box-shadow: 2.5px 2.5px 2.5px #888888;
border-radius: 4px;
z-index: 1;
}
nav h1 {
color: white;
margin-left: 20px;
}
nav ul {
margin-left: 27%;
list-style: none;
margin-top: -55px;
}
nav ul li {
border-radius: 2px;
float: left;
cursor: pointer;
margin-left: 5px;
display: inline;
padding: 21.5px;
background-color: #1AB188;
transition: all .5s ease;
box-shadow: 2.5px 2.5px 2.5px #0d1215;
}
nav ul li:hover {
box-shadow: 5px 5px 5px #0d1215;
}
nav ul li#pleb {
height: 19px;
}
nav ul li#pleb ul {
margin-top: -80px;
opacity: 0;
transition: all .5s ease;
}
nav ul li#pleb:hover ul {
opacity: 1;
margin-top: 30px;
}
nav ul li#pleb:hover {
height: 290px;
}
nav ul li:hover {
background-color: #179E79;
}
nav ul li ul.dropdwn li {
display: none;
margin-top: 20px;
margin-left: -90px;
}
nav ul li:hover ul.dropdwn li {
display: block;
}
nav ul li ul li:hover {
background-color: #2A3943;
}
nav ul li a {
color: white;
text-decoration: none;
}
nav ul li#fort {
height: 19px;
}
nav ul li#fort:hover {
height: 400px;
}
nav ul li#fort ul {
margin-left: -50px;
margin-top: -300px;
opacity: 0;
transition: all .5s ease;
}
nav ul li#fort:hover ul {
margin-top: 20px;
opacity: 1;
}
nav ul li#fort ul.drpdown li {
display: none;
margin-top: 10px;
}
nav ul li#fort:hover ul.drpdown li {
display: block;
}
nav .login ul {
list-style: none;
margin-top: 0px;
border-color: none;
}
nav .login ul li {
background-color: rgba(38, 181, 150, 0);
box-shadow: none;
margin-top: -80px;
margin-left: 770px;
transition: all .5s ease;
}
nav .login ul li:hover {
transform: translateX(-100px);
}
nav .login ul li img {
width: 40px;
}
nav .login ul li img:hover {
transform: none;
}
nav .login ul li ul li {
display: none;
margin-left: -30px;
margin-top: -60px;
transition: none;
background-color: rgba(119, 221, 110, 0);
}
nav .login ul li ul li#signup {
position: absolute;
margin-left: 20px;
margin-top: -60px;
}
nav .login ul li ul li#logout {
margin-left: -10px;
}
nav .login ul li:hover ul li {
display: block;
transform: none;
}
nav .login ul li ul li button {
border: none;
padding: 5px;
cursor: pointer;
background-color: rgba(164, 19, 34, 0);
color: #fff;
transition: all .5s ease;
}
nav .login ul li ul li button:hover {
background-color: #1AB188;
padding: 10px;
}
nav .login ul li ul li#signup button {
width: 80px;
}
<nav>
<h1>MemeStagram</h1>
<ul>
<li><a href="index.php">Home</a></li>
<li id="pleb"><a href="memes.php">Memes</a>
<ul class="dropdwn">
<li><a href="most-popular.php">Most Popular</a></li><br>
<li><a href="newest.php">Newest</a></li><br>
<li><a href="most-viewed.php">Most Viewed</a></li>
</ul>
</li>
<li><a href="about.php">About Us</a></li>
<li id="fort"><a href="contact.php">Contact</a>
<ul class="drpdown">
<li><a href="bebin.php">Bebin</a></li><br>
<li><a href="balbin.php">Balbin</a></li><br>
<li><a href="bohan.php">Bohan</a></li><br>
<li><a href="barcus.php">Barcus</a></li><br>
<li><a href="bonis.php">Bonis</a></li>
</ul>
</li>
<li><a href="settings.php">Settings</a></li>
</ul>
<div class="login">
<ul>
<li><img src="img/unlock.png">
<ul>
<li id="logout">
<a href="logout.php"><button type="submit">Logout</button></a>
</li>
</ul>
</li>
</ul>
</div>
</nav>
如果您能帮助我解决这个问题,我将不胜感激。我试图设置 position: absolute;和位置:固定;但它没有给我任何积极的结果......
//凯文
最佳答案
请在下面找到完全重写的代码,因为它到处都是,并且不符合标准。请仔细阅读以下代码并查看您哪里出错了,以了解有关 css 的更多信息。
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
* {font-family: arial;}
header {background-color: #2A3943;padding: 10px 40px;box-shadow: 2.5px 2.5px 2.5px #888888;border-radius: 4px;}
header nav h1 {display: inline-block;color: white;}
header nav {display: block;}
header nav ul {list-style: none; padding: 0px;display: block;}
header nav ul li {position:relative;display: inline-block;border-radius: 2px;cursor: pointer;padding: 22px;background-color: #1AB188;box-shadow: 2.5px 2.5px 2.5px #0d1215;margin:0px 5px;text-align: center;}
header nav ul li:hover > ul {visibility: visible;transform: translateY(0%);transition-delay: 0s, 0s, 0.3s;opacity: 1}
header nav ul li > ul {background-color:#1AB188;top:60px;visibility: hidden;position: absolute;width: 100%;transform: translateY(-2em);transition: all 0.3s ease-in-out 0s, visibility 0s linear 0.3s, z-index 0s linear 0.01s;left:0px;opacity: 0;}
header nav ul li a {text-decoration: none;color: white;display: block;}
header nav ul li a:hover {color: #333;}
header nav ul li:last-child {float: right;margin-right: 0px;padding: 20px 0px; background: none;box-shadow: none;}
header nav ul li:first-child {border-radius: none;padding: 0px;background-color:transparent;box-shadow: none;margin-right: 40px;}
header nav ul li:nth-child(2) {margin-left: 0px;}
header nav ul li:last-child > * {display: inline-block;vertical-align: middle;}
header nav ul li:last-child img {margin-right: 20px;width: 40px;}
header nav ul li:last-child:hover a button {visibility: visible;transform: translateX(0%);transition-delay: 0s, 0s, 0.3s;opacity: 1}
header nav ul li a button {padding: 5px;cursor: pointer;background-color: rgba(164, 19, 34, 0);color: #fff;visibility: hidden;transform: translateX(2em);transition: all 0.3s ease-in-out 0s, visibility 0s linear 0.3s;opacity: 0;}
header nav ul li > ul li {box-shadow: none;background: none;display: block;border-radius: 0px;margin:0px;padding: 21px !important}
header nav ul li > ul li:last-child {float: none;}
header nav ul li > ul li:first-child {margin: 0px;}
</style>
</head>
<body>
<div class="wrapper">
<header>
<nav>
<ul>
<li><h1>MemeStagram</h1></li>
<li><a href="index.php" title="Home">Home</a></li>
<li><a href="memes.php" title="Memes">Memes</a>
<ul>
<li><a href="most-popular.php" title="Most Popular">Most Popular</a></li><br>
<li><a href="newest.php" title="Newest">Newest</a></li>
<li><a href="most-viewed.php" title="Most Viewed">Most Viewed</a></li>
</ul>
</li>
<li><a href="about.php" title="About Us">About Us</a></li>
<li><a href="contact.php" target="Contact">Contact</a>
<ul>
<li><a href="bebin.php" title="Bebin">Bebin</a></li>
<li><a href="balbin.php" title="Balbin">Balbin</a></li>
<li><a href="bohan.php" title="Bohan">Bohan</a></li>
<li><a href="barcus.php" title="Barcus">Barcus</a></li>
<li><a href="bonis.php" title="Bonis">Bonis</a></li>
</ul>
</li>
<li><a href="settings.php" title="Settings">Settings</a></li>
<li class="login"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f4/Simpleicons_Interface_unlocked-padlock.svg/1024px-Simpleicons_Interface_unlocked-padlock.svg.png" alt="Login/Logout"><a href="logout.php" title="logout"><button type="submit">Logout</button></a></li>
</ul>
</nav>
</header>
</div>
</body>
</html>
由于您似乎对 css 很陌生,所以我将解释所使用的选择器:
> This selector means "directly inside" so when I put li > ul it means target the UL directly inside an li
* this selector means everything, where I have set everything to have font-famly:arial.
:hover this selector means on hover of the element its attached to, do something
:last-child this selector means the last child of the attached element
:first-child this selector means the first child the attached element
这是一个工作代码笔:https://codepen.io/anon/pen/MrPBEW
关于html - 一个在不应该移动的时候移动的 img,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48299993/
我想替换每一个 带结束标记 字符串中的标记。该字符串实际上是一个 html 文档,其中 img 标记由我生成,并且始终如下所示: Src 是用户输入,所以它可以是任何东西。我做了一个正则表达式,不确
我使用数组通过 getElementsByClassName 存储我所有的 imgs。 我需要知道哪个 img 被点击或 mouseover/mouseout,所以我使用循环来检查哪个 img 被点击
我正在尝试使用图像制作一款类似 Match3 的游戏,但我无法进行比较。我正在为固定数量的 atm 执行此操作,只是为了让它正常工作,稍后应该在 foreach 循环中。如果有什么区别的话,该函数位于
我希望你能帮助我:) 我想定义 img 的高度,相对于图像的“实际”宽度。但宽度是动态的,因为它占父对象的百分比(wxample 的浏览器窗口)。 为什么我需要高度?:没有高度它工作正常,但我需要它,
我知道这个话题被讨论了很多,但我找不到任何适合我的解决方案。所以,我的代码大致是: var img =me.images[curID] var f = function() { var
我试图在一个页面上列出多个图像,但当您单击图像时,它会以模式打开。 它适用于第一张图片,但不适用于其他图片,我假设这是一个 JS 问题,我尝试设置一个空的 var,然后将其设置为获取元素 ID(每个
任务:我们正在通过 HttpWebRequest 抓取 HTML 内容(约 6,000 个调用)。该字符串经过修剪并存储在 SQL Server 2014 数据库中,以便作为 XML 进行处理。 问题
我从上面得到这个错误,不知道如何避免它。我的目的是获取屏幕截图,然后对其进行模板匹配,以查看此时屏幕上是否显示图标。到目前为止,它只是图标的位置。我的代码: #include "opencv2/hig
我有一个包含图像的容器,该图像是从应用程序加载的,因此容器的尺寸是已知的,而图像会有所不同。 我目前有以下 css: #secondary_photos { height: 100px; wi
我正在尝试设置一个随分辨率缩放但看起来仍然不错的页面背景..这就是我正在使用的.. 站点是http://www.gd-gaming.com/wordpress ,如果你用 Firebug 检查它,它只
目前我有 如何删除包装 img 标签的 p 标签? 所以我可以得到.. 最佳答案 使用 $('p > img').unwrap(''); 这将删除 img 周围的所有 p。您应该使用 cl
我想要动画 3 .svg图片: 和css : .sequence { position: relative; } .sequence img { position: ab
我有外部 RSS 提要填充以下重复出现的类 elements 。 {teaserImage} {teaserImage} {teaserImage} 我想简单地获取 :first 实例,该实例也是来自
这是一个独特的问题: 我不想使用浏览器 JavaScript 来解决这个问题,请继续阅读... 我要转换 通过编译应用程序( ng build 或 ng serve )到 Base64 img 标签,
悬停在 中的第一张图片上标记,我需要使用 CSS 增加第二张图片的不透明度。我试过使用 +和 ~运营商,无法让它发挥作用。任何帮助将不胜感激。 最佳答案 a:hover + img
我已经尝试解决这个问题有一段时间了,但我迷路了,有人吗? for(var i=0; i<10; i++) { var Img = new Image(); Img.onload = (
这就是我想要实现的目标: 当用户将鼠标悬停在较小的图像之一上时: 较小的图像 + 文本应替换较大的图像 + 文本。 当用户没有悬停时;将大集返回到其原始图像和文字。 这就是我到目前为止所拥有的。它没有
我知道如何在 php 中执行此操作,但我需要在 javascript/jquery 中完成此操作。 我正在尝试执行以下操作: $('#NewBox').html( $('#OldBox').html(
我正在使用一个 CMS (ExpressionEngine),它将段落标签包裹在图像周围。我正在使用响应式图像(最大宽度:100%),并且由于我还在段落上定义宽度,因此它会导致问题。我想使用 jQue
Tinymce 正在删除我的 img 结束标记并生成无效的 xhtml。 它变成了这个 进入这个 我也在使用 codemagic,但是在查看 html 时它仍然显示 .我也试过包括 , 但输出是
我是一名优秀的程序员,十分优秀!