CSS Creating text-shadow overflow in a select element

I'm currently working on styling a menu with CSS, and I've encountered an issue with the text-shadow effect getting clipped inside the dropdown. It's surprising because I expected the text to spread into the padded area within the select borders.

    html,
    body {
        font-family: Calibri;
        margin: 0px;
        width: 100%;
        height: 100%;
        text-align: center;
        overflow: hidden;
        cursor: default;
    }

    #dropdown_user_select{
        position: absolute;
        left: 25px;
        top: 25px;
    }

    select {
        background: none;
        border: 1px solid;
        border-radius: 2px;
        box-shadow: 0px 0px 8px 0px #555, 0px 0px 25px 0px #555 inset;
        text-shadow: 0px 0px 10px #555;
        text-align: center;
        transition: 0.4s all ease-out;
        font-size: 25px;
        padding: 10px 10px 10px 30px;
        cursor: auto;
        -webkit-appearance: none;
        background: #DDD;
        overflow: visible;
    }

    .cutoff {
        overflow: visible;
    }

    #arrow_down {
        /* a customised arrow on the left of the dropdown */
        border-width: 15px 10px 0px 10px;
        border-color: #000 transparent transparent transparent;
        position: absolute;
        left: 30px;
        top: 45px;
    }
 <div class="cutoff">
    <select id="dropdown_user_select">
        <option value="ADMIN">ADMIN</option>
        <option value="username">username</option>
    </select>
 </div>
 <div id="arrow_down" class="arrow_pointer"></div>

Despite trying to use a div with overflow: visible to fix this issue, it hasn't been successful.

UPDATE

When I say clipping, I mean that the text-shadow is being cut off inside the <select> tag. Here's a more illustrative example:

    html,
    body {
        font-family: Calibri;
        margin: 0px;
        width: 100%;
        height: 100%;
        text-align: center;
        overflow: hidden;
    }

    #dropdown_user_select{
        position: absolute;
        left: 25px;
        top: 25px;
    }

    select {
        border: 1px solid;
        border-radius: 2px;
        text-shadow: 0px 0px 10px #F00;
        font-size: 25px;
        padding: 10px 10px 10px 30px;
        -webkit-appearance: none;
        background: #FFF;
        overflow: visible;
    }
<select id="dropdown_user_select">
    <option value="ADMIN">ADMIN</option>
    <option value="username">username</option>
</select>

Answer №1

One probable issue is that the padding cannot be applied directly to the <option> tag, causing the shadow to get cut off due to the pushed left edge from the select.

Through some clever workaround, it seems to function properly on Chrome, but hasn't been tested on other browsers yet (although it should work).

To address the left shadow problem, you can use the text-indent, while the line-height can resolve any vertical shadow issues.

select {
    border: 1px solid;
    border-radius: 2px;
    text-shadow: 0px 0px 20px #F00; /* increased to test vertical cut */
    text-indent: 20px; /* fix the left shadow */
    line-height: 40px; /* fix the top/bottom shadows */
    font-size: 25px;
    padding: 10px 10px 10px 0; /* removed left padding to compensate with indent */
    -webkit-appearance: none;
    background: #FFF;
    overflow: visible;
}
<select id="dropdown_user_select">
    <option value="ADMIN">ADMIN</option>
    <option value="username">username</option>
</select>

Answer №2

Understanding your goal can be tricky, but based on my interpretation, the text seems to overflow beyond the borders for you. I'm unsure about the shadows you mentioned... here's a JSfiddle link:

html, body {
  font-family: Calibri;
  margin: 0px;
  width: 100%;
  height: 100%;
  text-align: center;
  overflow: hidden;
  cursor: default;
}

#dropdown_user_select{
  position: absolute;
  left: 25px;
  top: 25px;
}

select {
  background: none;
  border: 1px solid;
  border-radius: 2px;
  box-shadow: 0px 0px 8px 0px #555, 0px 0px 25px 0px #555;
  text-shadow: 0px 0px 10px #555;
  text-align: center;
  transition: 0.4s all ease-out;
  font-size: 25px;
  padding: 10px 15px 10px 25px;
  cursor: auto;
  -webkit-appearance: none;
  background: #DDD;
  overflow: visible;
}

.cutoff {
  overflow: hidden;
}

#arrow_down {
  /* a customised arrow on the left of the dropdown */
  border-width: 15px 10px 0px 10px;
  border-color: #000 transparent transparent transparent;
  position: absolute;
  left: 30px;
  top: 45px;
}
<div class="cutoff">
  <select id="dropdown_user_select">
    <option value="ADMIN">ADMIN</option>
    <option value="username">username</option>
  </select>
</div>
<div id="arrow_down" class="arrow_pointer"></div>

Modifications were made to the overflow setting in .cutoff, and the inset was removed from the box shadow in select. The padding values were also adjusted to accommodate the width of the downward arrow. If this addresses your issue, I'm glad I could assist.

If the problem persists or if there are other issues, please provide further details so that I can offer more help.

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

Eliminate excess space around images in Bootstrap

I have an image tag with a padding applied to it. I am using the Bootstrap CSS framework. Currently, there is a white background behind the image that I want to remove and make it partially transparent instead. The image is in PNG format, so I suspect the ...

What's the best way to horizontally align two logos in the navigation bar?

Has anyone successfully placed 2 logos on the navbar in Materialize Framework side by side? I'm struggling to make it work and could use some help. Here is my CodePen for reference. I've experimented with the display property but haven't ...

What is the method of posting to PHP using JavaScript without utilizing Ajax?

My current code involves a drag and drop file uploader to PHP using ajax, but it seems that my web host does not support ajax. Is there an alternative method to achieve this without using ajax? Specifically, I am facing issues with the UploadFile functio ...

Having trouble with Gulp JS and CSS minification where existing minified files cannot be replaced

I've hit a roadblock in trying to resolve my search and google issue. My current challenge involves Gulp and cssmin. I can't seem to pinpoint the cause of an error. My aim is to have both the original CSS files and their minified versions in the ...

Creating a versatile TailwindCSS grid that can adjust to varying numbers of grid columns

I am currently working with Vue3 and TailwindCSS, attempting to create a grid using a dynamic grid-cols-{n} class. While I am aware that TailwindCSS typically supports up to 12 columns by default, the challenge arises when the number of columns needed is e ...

Difficulty in vertical alignment of inline-block elements

Greetings, I am currently working on creating a Resume in HTML. However, I seem to be facing an issue with the inline-block property as the two div elements that should be placed next to each other are not displaying as expected - one of them appears sligh ...

HTML code now launches in the existing electron window rather than opening a new window

<html> <head> <title></title> </head> <input type="button" name="new" id="newmon" value="new"> <button onclick="open1()">monitor 1</button&g ...

Attempting to change the primary color in Bootstrap is ineffective following a button click

I have been attempting to customize the primary color of Bootstrap 5 using SCSS. Everything works perfectly until I click a button that opens an external link. Below is the content of my SCSS file: $primary: #ae217aff; @import "../node_modules/boots ...

The EJS is causing a problem with linking the style sheet

Currently, I am in the process of familiarizing myself with ejs, express, and node js. Facing an issue while trying to link my style sheet to my header, below is the code snippet and here is a https://i.stack.imgur.com/0BEIn.png. Utilizing include for bo ...

The image width does not match the width of the table element

Currently, I am working on an HTML newsletter and facing an issue where the width of my image does not match the full width of the td tag, despite both having the same pixel value. The image appears as 180 pixels wide, whereas the td tag is set to be 186 ...

Align several labels and text areas in the center

I am facing an issue with aligning multiple labels and textareas together. Currently, they line up like this: __________________ | | | | Label:|__________________| However, I want them to appear as fol ...

Problem with Ajax-appended form element not functioning -

I'm struggling with this ajax form method code $.ajax({ type: "GET", url: "/MainPage/GetAllRecords", dataType: "json", contentType: "application/json; charset=utf-8", success: function (data ...

Is it possible to activate the :active pseudoclass by pressing the 'enter' key on the keyboard using solely CSS?

The CSS: a:focus { opacity: .75 } a:active { transform: translateY(4px) } The purpose: When keyboard users tab to the link, the :focus style serves as a visual indicator Upon pressing the enter key to activate the link, the :active style provides ...

Display a circular div containing information; upon hovering over it, reveal all details

Looking to create a layout with three circular divs side by side where the bottom of each circle displays the beginning of an information text. Upon hovering, the full text should be revealed: My initial approach involved setting the CSS properties for a ...

Is there a way to retrieve all "a" tags with an "href" attribute that contains the term "youtube"?

My goal is to capture all a tags that have the href attribute containing the word youtube. This task requires the use of jquery. ...

The screen reader is unable to interpret the text that is visible within the anchor tag

I have an Angular application with a dropdown menu implemented as shown below. When using the NVDA screen reader to navigate, only the content inside the aria-label attribute is being read when tab focused. However, I want it to also read the content (&ap ...

What causes the position: sticky; property to fail in React implementations?

Currently, I am facing a challenge in making two sidebars sticky so that they will follow as the user scrolls until they reach the bottom of the page. In my current editing project, this implementation seems to be more complex compared to other programs w ...

Managing iframes in React using reference methods

Trying to set the content of an iframe within a React component can be a bit tricky. There is a component that contains a handleStatementPrint function which needs to be called when the iframe finishes loading. The goal is to print the loaded iframe conten ...

Switch between CSS and jQuery styling

Here is a code snippet I'm using to toggle the visibility of content: $(function(){ $('#slider').css('display',''); $('#hideslider').click(function(){ $('#slider').slideToggle('slow&apos ...

Bootstrap 5 alert: The function `$(...).carousel` is not recognized

Despite browsing through numerous similar questions, none of the solutions seem to work for my issue. Listed below are some points I have checked: Jquery is loaded before bootstrap Bootstrap libraries are up to date Confirmation that bootstrap.min. ...