Troubleshooting problem regarding the use of visibility: hidden; and transition property in HTML

HTML Code:

<link rel="stylesheet" type="text/css" href="s.css"/>
<div id="xd"><ul>a</ul><</div>

CSS Code:

#xd ul {
    visibility: hidden;
    transition: all 1s;
}

When viewing this code on Chrome version 27, the "a" element briefly appears for 1 second before disappearing. How is this possible when using 'visibility: hidden;' CSS property?

I am curious to learn more about why this unexpected behavior is occurring.

Thank you in advance for your explanation.

Answer №1

When it comes to CSS, there is a distinction between using visibility:hidden and display:none. To address your specific concern, I recommend implementing the following approach:

CSS:

#xd ul {
    display: none;
    transition: all 1s ease-in-out;
}  

HTML:

<ul id="xd"><ul><li>a</li></ul></ul>

To further understand the contrast between these two properties, you can refer to this resource for more detailed information: http://www.w3schools.com/css/css_display_visibility.asp

In brief, as highlighted in the above link, using visibility:hidden will maintain the space around the element and impact the layout, whereas display:none removes the element from the page without influencing the rest of the layout. This may result in a Chrome quirk where the element with visibility:hidden is briefly displayed before being hidden.

For an example demonstration, you can view the JSFiddle here: http://jsfiddle.net/JKA8z/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Vue Error: "the main template must have one and only one root element"

Exploring My Component Setup components exposed: <template> <!--<post-form/>--> <div class="wrapper"> <b-table :data="posts"> <template slot-scope="props"> <b-table-column fie ...

Newbie's Dilemma: Issues with Html, Email, and Distribution Lists

I am looking to add a new feature to my website where users can enter their email address to receive a free promotion and be added to an announcement list. Since I don't have any experience with web programming, I'm not sure where to start. Would ...

Combining Bootstrap navigation with a hamburger menu icon

Can anyone suggest the most effective method in Bootstrap4 to showcase both a menu and a hamburger menu simultaneously within a navbar? The goal is to prioritize less important menu elements through the hamburger menu. Any assistance would be greatly app ...

Utilize JQuery variables for toggling the visibility of various DIV elements

On my webpage's splash page, there are 4 divs but only the home div is initially visible. The other three are hidden. Each of these divs has a button associated with it that triggers a jquery click event to swap out the currently visible div for the ...

Automatically press a button that appears on the webpage

I am looking to automate the clicking of a button that appears on a website. How can I accomplish this using Python? I have no experience in JavaScript and am fairly new to programming. Here is the outer HTML code for the button: <button type="button" ...

Applying CSS to inherit styles

I have a group of divs with a similar style, but each one has different padding and margin settings. Here is an example: <div class="mainStyle" id="cc">CC</div> <div class="mainStyle" id="bb">BB</div> <div class="mainStyle" id=" ...

One cool CSS trick: altering a div's background color with hover!

I'm working on creating a div that acts as a link to another page. My goal is to have the entire background color of the div change to blue when someone hovers over it. I want to achieve this effect using CSS only, as I am not sure if javascript will ...

Removing Inline Styles Using jQuery Scroll Event

Whenever I reach the scroll position of 1400 and then scroll back to the top, my chat elements (chat1, chat2, chat3, chat4) receive an "empty" inline style but only for a duration of 1 second. After that, the fadeIn effect occurs again every time I scroll ...

Having difficulty including text in the website header

I'm struggling to add text on the right side of my header. I have placed small images on the right side of the header, slightly below, and now I want to insert some text above them but I can't seem to get it to work. This is what I'm trying ...

Creating an overlay effect when hovering over an image

Recently, I've been working on a gallery of photos that showcases different individuals. My goal is to have information about each person displayed when their respective photo is hovered over - including their name and role. .gallery { position: ...

Having trouble with a nonresponsive link on a website? Unable to hover over it

The website can be found at: I've been trying to click on the "Home" link on the left side, but it doesn't seem to work for me. Any thoughts on why this might be happening? ...

Background positioning in IE8 does not display as intended

I'm experiencing an issue with the image background not displaying in IE8. You can view the page here, and the arrows on the accordion are not visible. Here is the CSS: .closed h2.accordion_h3 { background: url(mysource_files/down.png) no-rep ...

How can I make a div or iframe stretch to fill the remaining space using javascript, jQuery, or css?

I'm looking for a way to make the middle iframe dynamically fill the remaining space between two fixed height iframes (one at the top and one at the bottom) regardless of the window screen size. Is there a technique or method that can achieve this? th ...

PHP: Issues with displaying data from a SELECT * FROM query in tables

My goal is to style tables pulled from my database so that the columns in the rows align with the column names for better readability. I attempted to use PHP to achieve this by creating a table outside a while loop to display the names and then starting t ...

Upon loading the page, IE11 activates a CSS transition even when a media query that is not applied is present

Encountering a unique situation with IE11 where a panel (DIV) transition is only activated on pageload if a media query matched the highest CSS specificity for the element. The issue does not occur on Chrome, Firefox, or Safari on tablets and phones. The d ...

Struggles with closing dropdown menus

How can I modify my drop down menu so that the first drop box closes when a new link is clicked? Additionally, how do I ensure that the menu closes when clicking on a child item without refreshing the page (since the content is dynamically pulled from a ...

Setting expiration dates for cached images

I am interested in optimizing the loading speed of my webpage by setting an expiration date for images. However, I am unsure about where to specify this. The images on my website are loaded via CSS from Cloudfront using an S3 bucket in AWS. Can you provid ...

What are the steps to create a login form that is responsive by utilizing the Bootstrap grid system

.custom-border { border: 2px groove #000 !important; padding: 0px 5.4em 1.4em 6.4em !important; margin: 0 0 1.5em 0 !important; box-shadow: 0px 0px 0px 0px #000; margin-top: 30px !important; } .custom-legend { font-size: 1.2em !important; te ...

The mechanics of citing two different stylesheets

Just delving into the world of HTML and I'm attempting to link 2 items with href. Surprisingly, I don't receive an error message, but my style.css file refuses to cooperate. Any suggestions? <link rel="stylesheet" href="https://maxcdn.bootstr ...

Challenges I encountered with styling my navigation bar using CSS

My goal is to have the font color change to blue when a user hovers over a link in my navigation bar. I've tried using the following CSS code: #nav a:hover{ color: #1B8AD8; background: none; text-decoration: none; } However, it's not working as ...