简体   繁体   English

如何隐藏跨度 class 但保留它的空间

[英]how to hide span class but keep it's space

check the statement below:检查以下声明:

L1: HEY. L1:嘿。 YOU

<div>L1:<span class="lang1"> HEY </span>. <span class="lang1"> YOU</span> </div>

if I use this jQuery below如果我在下面使用这个 jQuery

    $(".btn").click(function () {
        $(".lang1").hide();
    });
});

it will hide HEY and YOU but it would then SHIFT THE.它会隐藏嘿和你,但它会转移。 SEPARATOR TO THE LEFT when they hide.当他们隐藏时,左边的分隔符。 how can I edit this to hide HEY and YOU but with keeping their spaces so that the.我如何编辑它以隐藏 HEY 和 YOU,但保留它们的空间以便。 separator remain still in the middle.分隔符仍然在中间。 I kinda think it has something to load a CSS class that is set to visibility:hidden / just not sure how to implement this / help plz?我有点认为它有一些东西可以加载 CSS class 设置为可见性:隐藏/只是不确定如何实现这个/帮助请?

Just set opacity to 0 in css with a class and use js to set this class to the span.只需在 css 中使用 class 将不透明度设置为 0,然后使用 js 将此 class 设置为跨度。

.lang1.opacity0{
   opacity:0; 
}

In JS在 JS 中

$(".btn").click(function () {
    $(".lang1").addClass('opacity0');
});

When you add class "opacity0" to the span it will now aplly the styles I entioned at the first.当您将 class “opacity0” 添加到跨度时,它现在将应用我最初提到的 styles。

Or hide text but with underscores using different class strategy applied with the same Jquery code:或者使用不同的 class 策略隐藏文本但带有下划线,并应用相同的 Jquery 代码:

.lang1.hidewithunderscore{
    color:transparent;
    border-bottom:1px solid #222;
}

In JS在 JS 中

$(".btn").click(function () {
    $(".lang1").addClass('hidewithunderscore');
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM