gpt4 book ai didi

javascript - 在透明选项卡后面隐藏边框

转载 作者:行者123 更新时间:2023-11-28 00:03:45 25 4
gpt4 key购买 nike

我正在试验一个选项卡脚本,它会根据您悬停在哪个选项卡上显示不同的信息。我试图在选项卡和主要内容窗口上使用透明背景颜色来执行此操作。选项卡的右边框是隐藏的,这很好,但是通过透明背景可以看到主要内容的边框。我希望图形从选项卡流向内容,但我无法弄清楚如何仅在 ACTIVE 选项卡右侧的位置隐藏边框。我创建了一个 JSFiddle 页面来提供视觉效果。

Tab Example - via JSFiddle

HTML:

<div id="vtab">
<ul>
<li class="home selected"></li>
<li class="login"></li>
<li class="support"></li>
</ul>
<div>
<h1>Profile 1</h1>
<p>This is where profile 1 will go</p>
</div>
<div>
<h1>Profile 2</h1>
<p>This is where profile 2 will go</p>
</div>
<div>
<h1>Profile 3</h1>
<p>This is where profile 3 will go</p>
</div>
</div>

CSS:

body {
background: black;
font-family: verdana;
padding-top: 50px;
color: white;
}
#vtab {
margin: auto;
width: 900px;
height: 100%;

}
#vtab > ul > li {
width: 440px;
height: 90px;
background-color: rgba(23,23,23,.5) !important;
list-style-type: none;
display: block;
text-align: center;
margin: auto;
padding-bottom: 10px;
border: 2px solid #a9a9a9;
border-radius: 15px 0 0 15px;
border-collapse: collapse;
position: relative;
border-right: none;
opacity: .3;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=30);
}

#vtab > ul > li.selected {
opacity: 1;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
border: 2px solid #a9a9a9;
border-right: none;
z-index: 10;
background-color: rgba(23,23,23,.5) !important;
position: relative;
}
#vtab > ul {
float: left;
width: 440px;
text-align: left;
display: block;
margin: auto 0;
padding: 0;
position: relative;
top: 80px;
}
#vtab > div {
background-color: rgba(23,23,23,.5);
margin-left: 440px;
border: 2px solid #a9a9a9;
min-height: 500px;
padding: 12px;
position: relative;
z-index: 9;
-moz-border-radius: 20px;
}

Javascript:

$(function() {
var $items = $('#vtab>ul>li');
$items.mouseover(function() {
$items.removeClass('selected');
$(this).addClass('selected');

var index = $items.index($(this));
$('#vtab>div').hide().eq(index).show();
}).eq(1).mouseover();
});

最佳答案

你可以让它在选定的 li 周围的伪元素中绘制边框

CSS

.selected:before {
content: '';
position: absolute;
right: 0px;
bottom: 100%;
width: 0px;
border-right: 2px solid #a9a9a9;
height: 1000px;
display: block;
}
.selected:after {
content: '';
position: absolute;
right: 0px;
top: 100%;
width: 0px;
border-right: 2px solid #a9a9a9;
height: 1000px;
display: block;
}

这会绘制伪元素。剩下的就是裁剪它们(因为我们不知道需要的尺寸:

    #vtab {
margin: auto;
width: 900px;
height: 100%;
overflow: hidden;
}

并停止在主 div 中绘制边框:

#vtab > div {
background-color: rgba(23,23,23,.5);
border-style: solid;
border-color: #a9a9a9;
border-width: 2px 2px 2px 0px;
}

updated fiddle

no backgrounds fiddle

关于javascript - 在透明选项卡后面隐藏边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19775665/

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