Tips for incorporating background color with CSS pseudo-elements

I'm attempting to replicate the outcome shown in the screenshot but I'm having difficulty achieving it without adding any new DOM elements.

When I click on the demo link and choose a date range, the start date and end date selections are not displaying as anticipated.

Here is the demo link

Answer №1

After experimenting with your CSS, I managed to achieve the desired result.

You could potentially try implementing something like this:

.DayPicker-Day--start {
    color: #fff !important;
    border-top-left-radius: 50% !important;
    border-bottom-left-radius: 50% !important;
}

.DayPicker-Day--end {
    color: #fff !important;
    border-top-right-radius: 50% !important;
    border-bottom-right-radius: 50% !important;
}

.DayPicker-Day--selected {
    background-color: #C4C4C4 !important;
    color: #1C1C1C;
    z-index: 1;
}

.DayPicker-Day--selected::after {
    content: '';
    position: absolute;
    background-color: #1C1C1C !important;
    width: 100%;
    height: 100%;
    z-index: -1;
    top: 0;
    right: 0;
    border-radius: 50%;
}

I suspect that the trouble may have been related to the z-index values.

If you're interested, here is a link to screenshots from my inspector tool which might offer some insight. I initially used #ccc as a placeholder and forgot to update it, so make sure to adjust that to the gray shade you prefer for your background.

Answer №2

Upon making the following adjustments, I was able to achieve the desired results:

  • Modifying the z-index: -1
  • Adjusting the selector to include left: 0 for --end
  • Applying width: 50%; & height: 100%

I then divided the original

.Selectable .DayPicker-Day--start:after, .Selectable .DayPicker-Day--end:after
selector into two separate entities as shown below:

.Selectable .DayPicker-Day--start:after{
      content: '';
      position: absolute;
      background-color: #f0f8ff!important;
      width: 50%;
      height: 100%;
      z-index: -1;
      top: 0;
      right: 0;
  }
  
  .Selectable .DayPicker-Day--end:after{
    content: '';
    position: absolute;
    background-color: #f0f8ff!important;
    width: 50%;
    height: 100%;
    z-index: -1;
    top: 0;
    left: 0;
}

The outcome of these modifications can be viewed at the following link: https://i.sstatic.net/J137v.png

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

Having trouble getting a background image to show up using node.js?

Hi there, I have a quick and simple question. I am attempting to include a div with a background-image in my *.ejs page file. <style> .signPage{ background-image: url("//back.jpg"); width: 98%; height: 98vh; top: ...

Absence of MVC5 Vanilla Layouts

Creating my first MVC5/Razor application from the ground up, I want to avoid including unnecessary references that cause bloat. In the Views folder, I have separate Home and Shared subfolders. The Home folder contains Index.cshtml, while the Shared folder ...

JavaScript animation is not functioning as expected

I created a div with the id of "cen" and gave it a height and width of 50px. $(document).ready(function() { $("#cen").animate({ height: 500px, width: "500px", }, 5000, function() { // Animation complete. }); }); Unfort ...

What is the significance of the error message "react/jsx-no-undef" when it says "'Input' is not defined"?

Can someone help me figure out why I'm getting 'Input' is not defined react/jsx-no-undef error in my code when trying to create an input field for name? The form with textarea is working fine. I will be passing the name into my dispatch fun ...

Tips for customizing the cursor to avoid it reverting to the conventional scroll cursor when using the middle click

When you wish to navigate by scrolling with the middle mouse button instead of using the scroll wheel, simply middle-click and your cursor will change allowing for easy scrolling on web pages. Even though I am utilizing style="cursor: pointer" and @click. ...

Conceal the header on signup and login pages using Material UI

I am working on a project with three pages: SignUp, Login, and Lists, along with a header component. My goal is to hide the header on the SignUp and Login pages, and only show it on the List page. Any suggestions on how I can achieve this? Here is my cod ...

Tips for creating a div element with a header and scrollable section

Greetings! I am currently developing a code to manage a sprinkler system interface with a modern and visually appealing design. At the moment, I have two columns on the page, each containing boxes. Unfortunately, the alignment of these boxes is not as desi ...

The function exclusively examines the final element within the array

When validating user-submitted emails in my function, I compare each email to a list of valid email domains. The user emails are stored in an array, as well as the valid email domains. However, the issue arises when using the function as it only checks if ...

Extending the length of the list items and their contents

Take a look at this website. I'm struggling with expanding the submenu list items in IE7. It seems that when you hover over one of the LIs under Restaurants, the green does not fill the entire line. I attempted using {width: 100%}, but it did not sol ...

Issue with transition effect not functioning properly when hovering in HTML and CSS

Is there a way to achieve a slow smooth transition when hovering over the .bg-gradient element and have the same effect when removing the cursor? Currently, the transition happens quickly on hover. .asc { height: 500px; background-position: 50%; ...

Using Laravel to connect custom fonts

After previously discussing and experimenting with linking custom font files in Laravel, I encountered an issue where the fonts were not displaying correctly on my website. Due to Laravel's router, directly linking to font files in CSS was posing a ch ...

When scrolling, the body content covers up the navbar

Whenever I try to scroll the page, the body contents start overlapping with the navbar. I have content over the navbar that should disappear when scrolling, and it is working correctly. The navbar should be fixed while scrolling, and this functionality ...

Scrolling automatically to a DIV is possible with jQuery, however, this feature is functional only on the initial

I'm currently working on a Quiz site and I've encountered a puzzling issue. Since the explanation only appears after an answer is selected - essentially a "hidden" element, I decided to wrap that explanation into a visible DIV. The code I'v ...

Tips for adjusting the height and border of Bootstrap tabs

I'm facing an issue with the modal and nav-tabs I created. There are a couple of problems that need to be addressed. Firstly, the tabs have excessive height and I've tried adjusting it using CSS height property, but it's not working as e ...

Exploring the contrasts in employing functions within a react-native environment

Imagine having a component called "wo" that receives a function as a parameter. export default class SomeComp extends Component { constructor(props) { super(props); } _someFunc = () => { return ... } render() { ...

Static assets in a React app hosted under Plesk cannot be accessed

Currently, I am attempting to launch a React application on Plesk Windows hosting. The React app was generated using the command create-react-app. To store static assets, I established a directory named build by utilizing the command npm run build. In th ...

Tips on displaying a selected choice | Utilizing Material UI Autocomplete

I have successfully fetched data from an API and used it as options in Material UI Autocomplete. However, when I select an option and send it back to the API using a POST request, the selected category is displayed as a number (0) instead of text, as shown ...

Impossible to create margins on both the left and right side

Check out this cool pen: http://codepen.io/helloworld/pen/BcjCJ?editors=110 I'm facing an issue where I'm unable to create both left and right margins around my datagrid. Only the left margin seems to be possible. Any suggestions on how I can f ...

Firefox and IE are unable to make changes to cssRules

To update existing global CSS rules, I access the document.styleSheets property to locate the rule and make modifications. The selector can be modified by accessing the selectorText property. Sample CSS code: <style type="text/css"> .class { ...

Errors with pointer events occurring within nested iframes on Chromium 78

At first glance, it seems like a bug specific to Chromium. I have already reported this issue in a bug report. Since progress is slow on that front, I am posting a question here primarily to see if anyone else has encountered similar or related issues and ...