我想创建一个带有播放按钮的图像,该按钮位于左下角,并将链接到另一页以播放音频文件。但是,我遇到了一些问题。首先,即使我明确使用具有透明背景的播放按钮,它也会给它一个白色背景,覆盖了它所在的图像。我尝试了“background-color: transparent;”来设置播放按钮的背景色,但没有效果。此外,我不知道如何调整我的播放按钮大小。我尝试通过“post”类和“post0001”id更改图像的宽度和高度,但似乎并没有起作用。如果这篇文章提出了太多问题,我很抱歉。以下是我的代码。非常感谢。
* {
margin: 0;
padding: 0;
background-color: rgb(300, 300, 300);
}
.topnav {
padding-top: 50px;
/*padding-left: 200px;*/
position: relative;
letter-spacing: 2px;
float: left;
}
.topnav a {
font-size: 20px;
color: black;
text-decoration: none;
border-bottom-width: 5px;
border-bottom-style: solid;
margin-bottom: 35px;
margin-left: 80px;
}
#episodes {
border-bottom-color: rgb(219, 50, 54);
}
#sources {
border-bottom-color: rgb(72, 133, 237);
}
#about {
border-bottom-color: rgb(244, 194, 13);
/*padding-left: 15px;
padding-right: 15px;*/
}
#contact {
border-bottom-color: rgb(60, 186, 84);
}
.post {
position: fixed;
margin-top: auto;
width: auto;
top: 120px;
}
#post0001 {
width: 500px;
height: 500px;
background-image: url(https://static.pexels.com/photos/298611/pexels-photo-298611.jpeg);
background-repeat: no-repeat;
padding-bottom: 200px;
padding-right: 350px;
padding-left: 15px;
padding-top: 45px;
}
.logo {
font-size: 80px;
color: black;
font-family: sans-serif;
float: left;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="dontgoogleit.css">
<div class=l ogo>
DGI
<!-- <img src = -->
</div>
<title>
pls dnt
</title>
<div class="topnav" id="myTopnav">
<a href="#episodes" id="episodes">EPISODES</a>
<a href="#sources" id="sources">SOURCES</a>
<a href="#about" id="about">ABOUT</a>
<a href="#contactus" id="contact">CONTACT US</a>
</div>
</head>
<body>
<div class="post" id="post0001">
<img src="http://www.pngmart.com/files/3/Play-Button-Transparent-Background.png" alt="Play Button" href="#episodeOne">
</div>
</html>
.post img
上设置宽度。或者您可以在.post
上设置宽度,然后添加.post img { max-width: 100%; }
以使图像与.post
一起调整大小。您还可以使用.post img { background: transparent; }
从图像中删除背景。 - Michael Coker