Best Website-BuildersBest Website-Builders
    What's Hot

    Insulate Britain protester jailed for stopping traffic on M4

    March 13, 2023

    BBC boss denies climbdown over Lineker impartiality row

    March 13, 2023

    David Saker appointed England fast bowling coach for Ashes and World Cup

    March 13, 2023
    Facebook Twitter Instagram
    Facebook Twitter Instagram
    Best Website-BuildersBest Website-Builders
    • Home
    • CSS

      Almost Bare Bone WebR Starter App

      March 12, 2023

      Best AI Tools for Web Designers (2023)

      March 12, 2023

      PSPad 5.0.7.770 | Neowin

      March 11, 2023

      Battle of Memphis

      March 11, 2023

      How to create a recipe book using HTML, CSS and JavaScript

      March 11, 2023
    • Joomla

      Mufti Menk – How can it be better for me?

      March 13, 2023

      Pros, Cons, & Pricing Compared

      March 11, 2023

      Give your website a place to call home for a lifetime of web hosting for just $100

      March 11, 2023

      Give your website a place to call home for a lifetime of web hosting for just $100

      March 11, 2023

      12 Best Free Web Hosting Sites to Choose From

      March 10, 2023
    • PHP

      Lawsuit says teacher pushed student for not saying pledge of allegiance

      March 12, 2023

      Paul Flores sentenced to 25 years for murder of Christine Smart

      March 12, 2023

      Most Effective Skin Serum, According to Reviewers and Dermatologists

      March 12, 2023

      Man sues ex-wife’s friend for helping ex-wife get abortion

      March 11, 2023

      Perfect indoor and outdoor slippers to wear around the house or on errands

      March 11, 2023
    • UX

      New Lexus RZ major on refinement and fresh thinking

      March 13, 2023

      Lexus RZ Review (2023) | Auto Car

      March 13, 2023

      Evolution of Tourism UI/UX Design: Trends to Watch

      March 13, 2023

      Introducing Qi and how to make wireless charging more pervasive

      March 13, 2023

      Which Product Designer Specialization is the most expensive?

      March 13, 2023
    • Web Builders
      1. Web Design
      2. View All

      What Comes First in Website Development — Design or Copy?

      February 2, 2023

      Modern Campus Honors Best Higher Education Websites of 2022

      February 2, 2023

      Premier SEO Consultant in Las Vegas, Nevada with Unparalleled Customer Service

      February 2, 2023

      Can Religious Freedom Be Saved? This group is racing the clock to teach America’s first freedom

      February 2, 2023

      How i Create New Google Account

      February 7, 2023

      CWT powers tools for meeting and event planners

      January 31, 2023

      Best Website Builder – Website Builders

      January 24, 2023

      Is There A Market For Rap-Themed Slot Games? – Rap Review

      January 19, 2023
    • WordPress

      Microsoft says most UK companies fail to recognize technology’s potential

      March 13, 2023

      No wonder Sonos wants to make a wireless soundbar.

      March 13, 2023

      iPhone 14 series cases probably won’t fit most iPhone 15 models.

      March 13, 2023

      Quordle today – Tips and Answers for Monday March 13th (Game #413)

      March 13, 2023

      A big Samsung Galaxy S23 camera update is rumored to be in the works

      March 12, 2023
    • Realtoz
      • Our Other Sites
    • More News
    Best Website-BuildersBest Website-Builders
    Home » Overtop Styling for Styled Components – HTML & CSS – SitePoint Forums
    CSS

    Overtop Styling for Styled Components – HTML & CSS – SitePoint Forums

    websitebuildersnowBy websitebuildersnowJanuary 19, 2023No Comments4 Mins Read
    Facebook Twitter LinkedIn Telegram Pinterest Tumblr Reddit WhatsApp Email
    Share
    Facebook Twitter LinkedIn Pinterest Email


    So I’m trying to think of a good way to do this, but I think my answer is “bite the bullet”.

    Consider the following HTML.

    <div id="calendarCanvasHeader" class="sc-ldQhTJ DnLdN">
    	<div name="calendarCanvasDayHeader" class="sc-tVThF kLhKBA">
    		...
    	</div>
    	<div name="calendarCanvasDayHeader" class="sc-tVThF kLhKBA">
    		...
    	</div>
    	<div name="calendarCanvasDayHeader" class="sc-tVThF kLhKBA">
    		...
    	</div>
    	<div name="calendarCanvasDayHeader" class="sc-tVThF bcLTPL">
    		...
    	</div>
    	<div name="calendarCanvasDayHeader" class="sc-tVThF kLhKBA">
    		...
    	</div>
    	<div name="calendarCanvasDayHeader" class="sc-tVThF kLhKBA">
    		...
    	</div>
    	<div name="calendarCanvasDayHeader" class="sc-tVThF kLhKBA">
    		...
    	</div>
    </div>
    

    (The contents of the inner div are irrelevant to the topic.)
    I’m trying to apply CSS on top of the site defaults (using Stylus/Stylish).

    The difference between “kLhKBA” and “bcLTPL” is that bcLTPL applies a background color.

    Class names are created programmatically and are subject to change.
    The div to which the “different” class is applied changes daily. (highlighting current day header)

    Is there a good way to select “weird stuff” without using a specific class name? I can’t think of one.

    I’m not the site creator, so I have no control over the HTML structure or classes.


    I don’t think it’s pure CSS.

    I’ve found JS to be used quite easily, especially when sc-tVThF is consistently present.

    • find all elements with that class
    • Loop through those elements, then loop through the class list and put them into an array. Perhaps the class name is the key and the value is the count key/value.
    • Sorting an array by value odds out the first entry.



    2 likes

    If there’s a non-CSS programming language feature here, is it possible that the weird header there corresponds to the day of the week? Is it easy to get without using the class name? You can create a selector like :nth-of-type() and point to it.



    1 like


    Paul OB


    January 19, 2023 at 4:09 PM


    Five

    Dave Maxwell:

    I don’t think it’s pure CSS.

    No, I also don’t know how to do this if I don’t know the class name or if the weird class name jumps to another div .



    2 likes

    I also don’t know how to do this with pure CSS. Many fixes have been made in JavaScript, but not in CSS.



    1 like

    One way to choose the “odd one out” without using a specific class name is to use CSS attribute selectors. You can target elements with specific attributes regardless of their value. For example, you can use the following CSS to target all divs with the name attribute “calendarCanvasDayHeader”.

    [name="calendarCanvasDayHeader"] {
      /* your styles here */
    }
    

    Then you can use the :not selector to exclude elements of class “kLhKBA”.

    [name="calendarCanvasDayHeader"]:not(.kLhKBA) {
      /* your styles here */
    }
    

    This will target all divs with name attribute “calendarCanvasDayHeader” that don’t have class “kLhKBA”.

    Another option is to use the nth-child selector. Allows you to select the nth element based on its position in the DOM. For example:

    [name="calendarCanvasDayHeader"]:nth-child(4) {
      /* your styles here */
    }
    

    This selects the 4th div with the name attribute “calendarCanvasDayHeader”.

    Note that this only selects the 4th element. Elements that change daily are not selected. The CSS should be updated daily according to the current position of the element.


    SAMA74


    January 21, 2023 at 5:31 PM


    Ten

    user:

    Then you can use the :not selector to exclude elements of class “kLhKBA”.

    The problems with this approach are:

    m_hutley:

    Class names are created programmatically and are subject to change.

    The selector will fail if the class name changes.

    user:

    This selects the 4th div with the name attribute “calendarCanvasDayHeader”.

    Again, this is a flawed approach given the following:

    m_hutley:

    The div to which the “different” class is applied changes daily. (highlighting current day header)



    1 like



    Source link

    Share this:

    • Tweet
    • Email
    • Pocket
    • Mastodon
    • WhatsApp
    • Telegram
    • Share on Tumblr
    • Print
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Telegram Email
    Previous ArticleETSU Storytelling Presenting Story Slam
    Next Article How to choose the best website builder for your business?
    websitebuildersnow
    • Website

    Related Posts

    Almost Bare Bone WebR Starter App

    March 12, 2023

    Best AI Tools for Web Designers (2023)

    March 12, 2023

    PSPad 5.0.7.770 | Neowin

    March 11, 2023
    Add A Comment

    Leave a Reply Cancel reply

    Top Posts

    Subscribe to Updates

    Get the latest sports news from SportsSite about soccer, football and tennis.

    Advertisement
    Demo

    This website provides information about CSS and other things. Keep Supporting Us With the Latest News and we Will Provide the Best Of Our To Makes You Updated All Around The World News. Keep Sporting US.

    Facebook Twitter Instagram Pinterest YouTube
    Top Insights

    Insulate Britain protester jailed for stopping traffic on M4

    March 13, 2023

    BBC boss denies climbdown over Lineker impartiality row

    March 13, 2023

    David Saker appointed England fast bowling coach for Ashes and World Cup

    March 13, 2023
    Get Informed

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    © 2023 bestwebsite-builders. Designed by bestwebsite-builders.
    • Home
    • About us
    • Contact us
    • DMCA
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.