简体   繁体   中英

Modifying css property of an element which is fixed at the top using javascript

I'm trying to take multiple screenshots in java selenium webdriver . Taking a site such as mashable.com , there is a static header at the top. When I take my first screenshot there is no problem but as I scroll down to take a screenshot, there is a header on top which blocks some content.

Now, I don't wish to have the header on top. Manually, I played around with the css of the site in chrome. I found that by identifying the id and setting the position from position from fixed to null , I get the header removed. Is it possible to have a general way to identify these headers (only on the top) and modify their css property using javascript ?

You can try this:

$('*').filter(function() {
if ($(this).css('position') === 'fixed'){
   $(this).css('position', 'relative');
}

});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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