gpt4 book ai didi

html - 如何为 2 个 div 使用相同的 CSS?

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

我有 2 个我希望样式相同的 div。一个叫做#popover,另一个叫做#recordViewPopover。这是我的弹出窗口的 CSS。如何让#recordViewPopover 使用与#popover 相同的 CSS?

#popover {
-webkit-border-radius: 4px;
-webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
-webkit-transition: opacity 0.25s linear;
-moz-border-radius: 4px;
-moz-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
-moz-transition: opacity 0.25s linear;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
transition: opacity 0.25s linear;
border: 3px solid black;
border-radius: 4px;
background-color: white;
color: black;
cursor: auto;
display: none;
font-weight: normal;
line-height: 1;
position: absolute;
right: 22px;
z-index: 5000000;
}

#popover > .popover_triangle
{
border-top: 16px solid rgba(0,0,0,0);
border-left: 16px solid rgba(0,0,0,0);
border-right: 16px solid rgba(0,0,0,0);
border-bottom: 16px solid black;
font-size: 0px;
line-height: 0%;
position: absolute;
top: -34px;
left:150px;
width: 0px;
}

#popover > .header
{
background: #222;
background: -moz-linear-gradient(top, #333 0%, #111 100%);
background-image: -webkit-gradient(
linear,
left top,
left bottom,
from(rgba(255, 255, 255, 0.55)),
color-stop(0.2, rgba(255, 255, 255, 0.35)),
color-stop(0.5, rgba(255, 255, 255, 0.1)),
color-stop(0.5, transparent),
to(transparent));
color: white;
font-weight: bold;
height: 27px;
line-height: 25px;
margin: 0;
padding: 3px;
text-shadow: rgba(0, 0, 0, 1) 0 -1px 0;
text-align: center;
}

#popover > .content
{
font-size: 12px;
max-height: 400px;
overflow-x: hidden;
overflow-y: auto;
width: 190px;
}

#popover > .content ul
{
list-style: none;
margin: 0;
padding: 0;
}

#popover > .content ul li
{
border-bottom: #ccc 1px solid;
line-height: 25px;
}

#popover > .content ul li.item:hover
{
border-bottom: #1443be 1px solid;
}

#popover > .content ul li h6
{
background: #f3f3f3;
display: block;
color: #000;
font-size: 13px;
padding: 0 10px;
text-shadow: rgba(255, 255, 255, 1) 0 -1px 0;
}

#popover > .content ul li a
{
display: block;
padding: 0 14px;
}

#popover > .content ul li a:link,
#popover > .content ul li a:visited
{
text-decoration:none;color:#333;
}

#popover > .content ul li a:focus,
#popover > .content ul li a:hover
{
background: #5396e3 url('../images/arrow-small.png') 97% center no-repeat;
color: #fff;
text-decoration: none;
text-shadow: rgba(0, 0, 0, .55) 0 -1px 0;
}

这是我的div

<div id='popover'> 
<div class='popover_triangle'></div>
<div class='header'>OPTIONS</div>
<div class='content'>
<ul>
<li><h6>OBJECT VIEW</h6></li>
<li class='item'><a onclick=\"$(document).trigger('objectViewFiltersEnabled', [ !filtersEnabled ]);\">Filters</a></li>
<li class='item'><a href=\"#\" >Configuration</a></li>
<li><h6>OBJECT</h6></li>
<li class='item'><a href=\"#\" >Configuration</a></li>
<li class='item'><a href=\"#\" >Documentation</a></li>
</ul>
</div>
</div>

<div id='recordViewPopover'>
<div class='popover_triangle'></div>
<div class='header'>OPTIONS</div>
<div class='content'>
<ul>
<li><h6>Information</h6></li>
<li class='item'><a href='#' >Change Logs</a></li>
<li><h6>Actions</h6></li>
<li class='item'><a href='#' >Assign</a></li>
<li class='item'><a href='#' >Share</a></li>
<li class='item'><a href='#' >Convert</a></li>
<li class='item'><a href='#' >Copy</a></li>
<li class='item'><a href='#' >Clone</a></li>
<li class='item'><a href='#' >Merge</a></li>
<li class='item'><a href='#' >Refresh</a></li>
<li class='item'><a href='#' >Delete</a></li>
</ul>
</div>
</div>

最佳答案

你会给他们分配同一个类(class)。为此,您需要:

<div id='popover' class='someName'>

<div id='recordViewPopover' class='someName'>

您的 CSS 将被声明:

.someName {
//Add styles here
}

关于html - 如何为 2 个 div 使用相同的 CSS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7650637/

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