Best Website Builders CompanyBest Website Builders Company
    What's Hot

    SBI Amrit Kalash Fixed Deposit last date extended, 7.6% interest for Senior Citizens. Details here

    May 17, 2023

    Number of UHNWIs in India dip to 12,069 in 2022, to rise to 19,119 in 5 years: Knight Frank

    May 17, 2023

    Share market tomorrow: Nifty, Bank Nifty support, resistance for Thursday 18 May

    May 17, 2023
    Facebook Twitter Instagram
    Facebook Twitter Instagram
    Best Website Builders CompanyBest Website Builders Company
    • Home
    • Web Builders
      1. Joomla
      2. WordPress
      3. CSS
      4. Web Design
      5. UX
      6. PHP
      7. View All

      For $50 you can host your website for life

      May 2, 2023

      California Department of Justice Investigating Shooting Involving CHP Officer in Glenn County Under AB 1506

      May 1, 2023

      Mariposa County Daily Sheriff and Reservation Report for Sunday, April 30, 2023

      May 1, 2023

      Top 10 Best Web Development Companies In India In 2023

      May 1, 2023

      Google Ads Sign Up – Easy Steps to Create Your Account

      May 17, 2023

      1Password puts users at ease after the horror of password change notifications

      May 3, 2023

      Samsung Galaxy S23 FE could feature a 50MP main camera, but we may have to wait until then

      May 3, 2023

      Titanfall director says Respawn is ‘looking forward to something new’

      May 3, 2023

      Implementing CSS with character and spirit: Union MoS Finance

      May 3, 2023

      Street Fighter 6’s unique character select screen animation really shows how much heart goes into the game

      May 3, 2023

      Make Google Chrome run faster with these 9 tips and tweaks

      May 3, 2023

      🅰️ New Angular 16 Goes Big in 2023: Everything You Need to Know | Vitaly Shevchuk | Oct 25, 2017 May 2023

      May 3, 2023

      18-Wheeler Accidents: Fatalities and Injuries

      May 6, 2023

      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

      The role of artificial intelligence in improving the user experience in online casinos.

      May 3, 2023

      Microsoft enhances user experience with Windows 11 ‘smart opt-out’ and improved emergency notifications

      May 3, 2023

      Nigeria’s Nestcoin Launches New Digital Financial Platform For Africans

      May 3, 2023

      ibi WebFOCUS 9.2 is ready for Modern Business Intelligence, the Cloud, and Driving User Experience – PCR.

      May 3, 2023

      Anthony Carrigan Reflects on That ‘Barry’ Scene from Season 4 Episode 4

      May 1, 2023

      TikToker Kat Abu is very happy that Tucker Carlson has been fired

      April 28, 2023

      How ‘Single Drunk Female’ Season 2 Tackled Emotional Sobriety

      April 24, 2023

      Trans-Missouri Residents Affected by Attorney General Order

      April 24, 2023

      Creating and Adding a Google Account: A Step-by-Step Guide

      May 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
    • Realtoz
      • Our Other Sites
    • More News
    • Investments
    Best Website Builders CompanyBest Website Builders Company
    Home»CSS»Parent background visible only from child elements – HTML & CSS – SitePoint Forums
    CSS

    Parent background visible only from child elements – HTML & CSS – SitePoint Forums

    websitebuildersnowBy websitebuildersnowMarch 9, 2023No Comments2 Mins Read
    Facebook Twitter LinkedIn Telegram Pinterest Tumblr Reddit WhatsApp Email
    Share
    Facebook Twitter LinkedIn Pinterest Email


    I wanted to display the parent’s gradient from the child’s shape.

    I tried adding ::after I parent it with a white background to hide the parent’s background color, but the child’s background is also white.

    Currently: https://jsfiddle.net/5kn6smj8/4/

      <div id="parent">
        <div class="child top-10"></div>
        <div class="child top-20"></div>
        <div class="child top-40"></div>
        <div class="child top-60"></div>
      </div>
    
    #parent {
      background: linear-gradient(#e66465, #9198e5);
      width: 100px;
      height: 300px;
    }
    .child {
      position: relative;
      width: 50px;
      height: 50px;
      border: 1px solid blue;
      border-radius: 50%;
      color: white;
    }
    .top-10 {
      top: 10px;
    }
    .top-20 {
      top: 20px;
    }
    .top-40 {
      top: 40px;
    }
    .top-60 {
      top: 60px;
    }
    

    Be expected:

    Be expected

    Also, the position of the child can be changed.


    Hello emoiishaaq,

    You may want to check if this code does what you want…

    HTML

    <body>
     <div id="parent">
      <div></div>
      <div></div>
      <div></div>
      <div></div>
     </div>
    </body>

    CSS

    body {
       background-color: #f9f9f9;
       font: normal 1em / 1.5em  sans-serif;
     }
    #parent {
       width: 3.19em;
       padding: 1em 2em;
       margin: 1em auto;
       border: 1px solid #000;
       border-radius: 0.5em;
       background-color: #fff;  
       box-shadow: 0.4em 0.4em 0.4em rgba( 0, 0, 0, 0.4 );
     }
    #parent > div {
      width: 3.125em;
      height: 3.125em;
      border: 1px solid #00f;
      border-radius: 50%;
      background-image: linear-gradient(#e66465, #9198e5);
      background-size: 3.25em 18.75em;
     }
    #parent >  div:nth-of-type(1) {
       margin-bottom: 0.625em;
     }
    #parent >  div:nth-of-type(2) {
       margin-bottom: 1.25em;
       background-position: 0 -3.75em
     }
    #parent >  div:nth-of-type(3) {
       margin-bottom: 1.875em;
       background-position: 0 -8.1255em
      }
     #parent > div:nth-of-type(4) {
       margin-bottom: 1.25em;
       background-position: 0 -13.125em
      }



    Source link

    Share this:

    • Tweet
    • More
    • WhatsApp
    • Print
    • Share on Tumblr
    • Mastodon

    Related

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Telegram Email
    Previous ArticleJennifer Lawrence is reinventing herself for a comeback
    Next Article Creed 3 is coming to Prime Video soon, but it won’t be available to stream for free
    websitebuildersnow
    • Website

    Related Posts

    Implementing CSS with character and spirit: Union MoS Finance

    May 3, 2023

    Street Fighter 6’s unique character select screen animation really shows how much heart goes into the game

    May 3, 2023

    Make Google Chrome run faster with these 9 tips and tweaks

    May 3, 2023
    Add A Comment

    Leave a Reply Cancel reply

    Post Your Ad Free
    Advertisement
    Demo
    Top Posts

    Subscribe to Updates

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

    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

    SBI Amrit Kalash Fixed Deposit last date extended, 7.6% interest for Senior Citizens. Details here

    May 17, 2023

    Number of UHNWIs in India dip to 12,069 in 2022, to rise to 19,119 in 5 years: Knight Frank

    May 17, 2023

    Share market tomorrow: Nifty, Bank Nifty support, resistance for Thursday 18 May

    May 17, 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.

    x