gpt4 book ai didi

html - 嵌套选项卡之间的空间

转载 作者:太空宇宙 更新时间:2023-11-03 21:20:47 27 4
gpt4 key购买 nike

任何人都可以解释为什么在嵌套选项卡中我将它放在第二个选项卡(名为“Letture”的选项卡)中,选项卡右侧有一个空格,而在第一个选项卡中却没有?

两个选项卡的 CSS 代码相同,我不明白为什么它们的行为不同

$('ul.tabs li').click(function(){
var tab_id = $(this).attr('data-tab');

$('ul.tabs li').removeClass('current');
$('.tab-content').removeClass('current');

$(this).addClass('current');
$("#"+tab_id).addClass('current');

$('ul.tabs li').each(function () {
var nimg = $(this).find('img').attr('src');
$(this).find('img').attr('src', nimg.replace('_r', '_g'));
});

var img = $(this).find( 'img' ).attr('src');
$(this).find( 'img' ).attr('src', img.replace('_g', '_r'));

});
$("ul.subtabs li").click(function(){
var tab_id = $(this).attr("data-tab");

$("ul.subtabs li").removeClass("current");
$(".subtab-content").removeClass("current");

$(this).addClass("current");
$("#"+tab_id).addClass("current");

$("ul.subtabs li").each(function () {
var nimg = $(this).find("img").attr("src");
$(this).find("img").attr("src", nimg.replace("_r", "_g"));
});

var img = $(this).find( "img" ).attr("src");
$(this).find( "img" ).attr("src", img.replace("_g", "_r"));
});
ul.tabs, ul.subtabs{
margin: 0px;
padding: 0px;
list-style: none;
}
ul.tabs li, ul.subtabs li{
line-height: 24px;
background: #ededed;
color: #777;
display: inline-block;
padding: 10px 40px;
cursor: pointer;
font: 16pt arial,verdana !important;
border: 1px solid rgb(164, 162, 162);
border-right: medium none;
}

ul.tabs li.current, ul.subtabs li.current{
background: none;
color: rgb(227,32,46);
border-bottom: 0;
border-top: 3px solid rgb(227,32,46);
padding-top: 8px;
}

.tab-content, .subtab-content {
display: none;
padding-top: 15px;
}

.tab-content.current, .subtab-content.current {
display: inherit;
}

ul.tabs > li > img, ul.subtabs > li > img {
margin-right: 5px;
width: 24px;
height: 24px;
}

.tabLast {
border-right: 1px solid rgb(164, 162, 162) !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<ul class="tabs">
<li data-tab="tab-1" class="tab-link"><img style="float:left;" src="http://www.fantamondi.it/silcam/images/pencil_g.png"> Amministratore</li><li data-tab="tab-2" class="tab-link current"><img style="float:left;" src="http://www.fantamondi.it/silcam/images/pencil_r.png"> Letture</li><li data-tab="tab-3" class="tab-link"><img style="float:left;" src="http://www.fantamondi.it/silcam/images/pencil_g.png"> Unità immobiliari</li><li data-tab="tab-5" class="tab-link tabLast"><img style="float:left;" src="http://www.fantamondi.it/silcam/images/pencil_g.png"> Riparti</li></ul>
<div data-loaded="1" class="tab-content" id="tab-1"><div class="mb20">&nbsp;</div><h3>Amministratore</h3></div>
<div data-loaded="1" class="tab-content current" id="tab-2"><ul class="subtabs">
<li data-tab="tab-af" class="tab-link"><img style="float:left;" src="http://www.fantamondi.it/silcam/images/pencil_g.png"> Acqua fredda</li>
<li data-tab="tab-ac" class="tab-link"><img style="float:left;" src="http://www.fantamondi.it/silcam/images/pencil_g.png"> Acqua calda</li>
<li data-tab="tab-ca" class="tab-link tabLast current"><img style="float:left;" src="http://www.fantamondi.it/silcam/images/pencil_r.png"> Calore</li>
</ul><div id="tab-af" class="subtab-content" data-loaded="1">Freddo!</div>
<div id="tab-ac" class="subtab-content" data-loaded="1">Caldo!</div>
<div id="tab-ca" class="subtab-content current" data-loaded="1">Calore!</div>
</div>

最佳答案

这是因为它们显示为 inline-block ,这是一个内联元素,因此会产生间隙,因此解决此问题的一种方法是设置 font-size:0 到父 ul

查看更多信息 here

$('ul.tabs li').click(function() {
var tab_id = $(this).attr('data-tab');

$('ul.tabs li').removeClass('current');
$('.tab-content').removeClass('current');

$(this).addClass('current');
$("#" + tab_id).addClass('current');

$('ul.tabs li').each(function() {
var nimg = $(this).find('img').attr('src');
$(this).find('img').attr('src', nimg.replace('_r', '_g'));
});

var img = $(this).find('img').attr('src');
$(this).find('img').attr('src', img.replace('_g', '_r'));

});
$("ul.subtabs li").click(function() {
var tab_id = $(this).attr("data-tab");

$("ul.subtabs li").removeClass("current");
$(".subtab-content").removeClass("current");

$(this).addClass("current");
$("#" + tab_id).addClass("current");

$("ul.subtabs li").each(function() {
var nimg = $(this).find("img").attr("src");
$(this).find("img").attr("src", nimg.replace("_r", "_g"));
});

var img = $(this).find("img").attr("src");
$(this).find("img").attr("src", img.replace("_g", "_r"));
});
ul.tabs,
ul.subtabs {
margin: 0px;
padding: 0px;
list-style: none;
font-size:0
}
ul.tabs li,
ul.subtabs li {
line-height: 24px;
background: #ededed;
color: #777;
display: inline-block;
padding: 10px 40px;
cursor: pointer;
font: 16pt arial, verdana !important;
border: 1px solid rgb(164, 162, 162);
border-right: medium none;
}
ul.tabs li.current,
ul.subtabs li.current {
background: none;
color: rgb(227, 32, 46);
border-bottom: 0;
border-top: 3px solid rgb(227, 32, 46);
padding-top: 8px;
}
.tab-content,
.subtab-content {
display: none;
padding-top: 15px;
}
.tab-content.current,
.subtab-content.current {
display: inherit;
}
ul.tabs > li > img,
ul.subtabs > li > img {
margin-right: 5px;
width: 24px;
height: 24px;
}
.tabLast {
border-right: 1px solid rgb(164, 162, 162) !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<ul class="tabs">
<li data-tab="tab-1" class="tab-link">
<img style="float:left;" src="http://www.fantamondi.it/silcam/images/pencil_g.png">Amministratore</li>
<li data-tab="tab-2" class="tab-link current">
<img style="float:left;" src="http://www.fantamondi.it/silcam/images/pencil_r.png">Letture</li>
<li data-tab="tab-3" class="tab-link">
<img style="float:left;" src="http://www.fantamondi.it/silcam/images/pencil_g.png">Unità immobiliari</li>
<li data-tab="tab-5" class="tab-link tabLast">
<img style="float:left;" src="http://www.fantamondi.it/silcam/images/pencil_g.png">Riparti</li>
</ul>
<div data-loaded="1" class="tab-content" id="tab-1">
<div class="mb20">&nbsp;</div>
<h3>Amministratore</h3>
</div>
<div data-loaded="1" class="tab-content current" id="tab-2">
<ul class="subtabs">
<li data-tab="tab-af" class="tab-link">
<img style="float:left;" src="http://www.fantamondi.it/silcam/images/pencil_g.png">Acqua fredda</li>
<li data-tab="tab-ac" class="tab-link">
<img style="float:left;" src="http://www.fantamondi.it/silcam/images/pencil_g.png">Acqua calda</li>
<li data-tab="tab-ca" class="tab-link tabLast current">
<img style="float:left;" src="http://www.fantamondi.it/silcam/images/pencil_r.png">Calore</li>
</ul>
<div id="tab-af" class="subtab-content" data-loaded="1">Freddo!</div>
<div id="tab-ac" class="subtab-content" data-loaded="1">Caldo!</div>
<div id="tab-ca" class="subtab-content current" data-loaded="1">Calore!</div>
</div>

关于html - 嵌套选项卡之间的空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37590240/

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