Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7055041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:42:01+00:00 2026-05-28T03:42:01+00:00

For example I want to find all elements that have computed style position: fixed;

  • 0

For example I want to find all elements that have computed style position: fixed;. How to do it without making much load on the CPU ?

Is iterating every getElementsByTagName('*') and then doing for loop the only way ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:42:01+00:00Added an answer on May 28, 2026 at 3:42 am

    Instead of selecting all (*) elements, and use getComputedStyle + getPropertyValue, you can follow the following steps:

    • Loop through all CSS rules (via document.styleSheets [1]) and take the selectors which contains position: fixed.

    • Select all elements whose style attribute contains position: fixed.

    • Use document.querySelectorAll to select all elements which match the selector.

      • Test whether window.getComputedStyle(elem, null).getPropertyValue('position') equals fixed to filter elements which are not at a fixed position (possibly overridden through a more specific selector, or !important).
      • If it matches, push the element in an array
    • At this point, you have an array containing all position: fixed elements.

    [1] The external stylesheets have to be located at the same origin, because of the Same origin policy.

    Code (small demo: http://jsfiddle.net/GtXpw/):

    //[style*=..] = attribute selector
    var possibilities = ['[style*="position:fixed"],[style*="position: fixed"]'],
        searchFor = /\bposition:\s*fixed;/,
        cssProp = 'position',
        cssValue = 'fixed',
        styles = document.styleSheets,
        i, j, l, rules, rule, elem, res = [];
    
    for (i=0; i<styles.length; i++) {
        rules = styles[i].cssRules;
        l = rules.length;
        for (j=0; j<l; j++) {
            rule = rules[j];
            if (searchFor.test(rule.cssText)) {
                possibilities.push(rule.selectorText);
            }
        }
    }
    possibilities = possibilities.join(',');
    possibilities = document.querySelectorAll(possibilities);
    l = possibilities.length;
    for (i=0; i<l; i++) {
       elem = possibilities[i];
       // Test whether the element is really position:fixed
       if (window.getComputedStyle(elem, null).getPropertyValue(cssProp) === cssValue) {
           res.push(elem);
       }
    }
    res; //<-- = Array containing all position:fixed elements
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys, I want to make a function loop over all elements that have
I'm trying to use XPath to find all elements that have an element in
Example: find / * Gives me all files and directories, but I want only
I want that find empty tags, here is a example txt =<lol1><><lol2> rgx =
I have a bunch of divs that are all hidden like this <div class=elements>
I want to find a date after a give weeks(months). For example, I want
I want to scale images these day and find the following example: Example #1
i want to split the searchrequest into parts, if there's nothing to find. example:
Where can I find the spec of CLR ? For example, I want to
for example : I want to remove all highlighted tags alt text http://shup.com/Shup/299976/110220132930-My-Desktop.png

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.