简体   繁体   English

隐藏大元素而不使用display:none或visible:hidden

[英]Hide a large element without using display:none or visibility:hidden

Is it possible to hide an element without using display:none, visibility:hidden or opactiy:0 CSS rules? 是否可以在不使用display:none,visible:hidden或opactiy:0 CSS规则的情况下隐藏元素?

At the moment anything I try, the content of the still remains relatively the same (Note: I am using Bootstrap 3) 目前,我尝试执行任何操作时,内容仍然保持相对不变(注意:我使用的是Bootstrap 3)

I mostly need to only use elements that are normally used for styling, rather than hiding/showing the content directly, so things like Opacity, display:none and visibility:hidden wouldn't work. 我通常只需要使用通常用于样式设置的元素,而不是直接隐藏/显示内容,因此诸如不透明度,显示:无和可见性:隐藏之类的东西将不起作用。 (It's to show some bad behaviour I found in a particular version of a browser, wanted to confirm it on other browsers with a controlled set) (这是为了显示我在特定版本的浏览器中发现的一些不良行为,希望在具有受控集的其他浏览器上进行确认)

Sorry guys, I managed to figure it out immediately after posting, what I used: 抱歉,我在发布后立即设法弄清楚了我的用法:

position:fixed !important;
height:1px !important;
width:1px !important;
bottom:0 !important;
left:0 !important;
z-index:-999 !important;
display:inline !important;

Just to give some more context into the CSS rules given above. 只是为了在上面给出的CSS规则中提供更多背景信息。 Height and width as 1px for the obvious reasons of making it as small as possible. 明显的原因是将高度和宽度设置为1px尽可能小。 The position being fixed but placing it constantly outside of the browsers visibility by place it at the 0th pixel from the bottom and the 0th pixel from the left. 该位置是固定的,但始终放置在浏览器可见性之外,方法是将其放在底部的第0个像素处,并将其放在左侧的第0个像素处。 I made everything !important so it over rides anything that might be cascaded. 我所做的一切都非常重要!因此,它超越了所有可能层叠的东西。

Try opacity:0; 尝试opacity:0; . This will make that element transparent. 这将使该元素透明。

.classname{
    position:absolute; 
    left:-2000px;
}

暂无
暂无

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

相关问题 隐藏元素而不使用 display:none 或 visibility:hidden - Hiding an element without using display:none or visibility:hidden 隐藏元素但保留给屏幕阅读器(不能使用display:none,visibility:hidden或opacity:0) - Hide Element but Preserve for Screen Readers (can't use display:none, visibility:hidden, or opacity:0) 使用可见性:隐藏和显示:CSS中没有? - Using visibility: hidden and display: none together in CSS? 隐藏元素而不在jquery中将显示设置为none - hide element without setting the display to none in jquery display:none 和 visibility:hidden 都不起作用 - Both display:none and visibility:hidden not working 可见性:隐藏和显示之间的性能差异:无 - Performance differences between visibility:hidden and display:none 避免隐藏的元素占用空间/无法使visible:true最初显示为:css样式中没有 - avoid hidden element occupying space/not possible to make visibility:true which is initially made display:none in css style Jquery 认为我<g>元素可见,即使显示设置为无和/或可见性设置为隐藏</g> - Jquery thinks my <g> element is visible, even when display is set to none and/or visibility is set to hidden 显示:无或可见性:在页面加载时隐藏在body元素上 - 它是否会影响SEO? - Display:none or visibility:hidden on body element on page load - does it affect SEO? 如果在jQuery中不显示任何元素,则更改另一个元素的可见性 - Change visibility of another element if display none in jQuery
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM