我在下拉菜单中有一张图片,希望成为下拉菜单的完整背景。我将图像设置为背景,但是如您所见,仍然有白色。如何仅使下拉菜单中的图像和其中包含滚轮?
在我看来,如何将滚轮css更改为图像?
(我将背景设为绿色以展示我不想显示的内容)
下拉CSS
.dropdown-menu {
width: 100%;
background-image: url('Res/IM/page.png');
background-size: 100% 100%;
background-color: #1e7e34;
}
相关下拉代码
<div id="inv1" class="dropdown-menu" style="min-height: 35vh; resize: vertical;background-image: url('Res/IM/page.png'); background-size: 100% 100%;" >
<div class="scrollable">
<a href="#" data-toggle="collapse" data-target="#inv1" class="dropdown-header text-right">X</a>
<CODE IS HERE AND IRRELEVANT>
</div>
</div>
答案 0 :(得分:1)
你是说这个吗?
.dropdown-menu {
background: url(https://t4.ftcdn.net/jpg/01/08/13/09/240_F_108130971_d2e6YQdGAfERW4p75YuJPQQsGZZXk41D.jpg);
background-size: 100% 100%;
background-color: transparent ;
}
a.dropdown-item {
color: red;
font-weight:bold
}
a.dropdown-item:hover {
background-color: transparent ;
color:white;
}
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap Example</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="dropdown">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
Dropdown button
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Link 1</a>
<a class="dropdown-item" href="#">Link 2</a>
<a class="dropdown-item" href="#">Link 3</a>
</div>
</div>
</body>
</html>
答案 1 :(得分:1)
.dropdown-menu{
background-image: url('https://images.pexels.com/photos/949587/pexels-photo-949587.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500');
background-size: 100% 100%;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<div class="dropdown">
<button type="button" class="btn dropdown-toggle" data-toggle="dropdown">
Dropdown button
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Link 1</a>
<a class="dropdown-item" href="#">Link 2</a>
<a class="dropdown-item" href="#">Link 3</a>
</div>
</div>