Tips on adjusting the width of a border

I'm facing a challenge with my select box setup:

<select class="selectpicker" multiple data-live-search="true" name="color[]" title="Nothing selected yet">

<option class="" style="border-bottom:2px solid; border-color:red" value="">Red</option>
<option class="" style="border-bottom:2px solid; border-color:black" value="">Black</option>
<option class="" style="border-bottom:2px solid; border-color:white" value="">White</option>


</select>

My goal is to have a line under each option text, similar to the image below:

https://i.sstatic.net/IF564.png

However, I want the line to be only under the text itself, like "Red", and not full-width as shown in the example.

I attempted to adjust the width, but that didn't provide the desired outcome since I need the option to remain fully clickable.

Answer №1

If you want to restrict the underline to just the text, consider using text-decoration instead of a border. (Make sure to select a font that doesn't have underlines overlapping Persian characters):

option {text-decoration: underline;}
<select style="width:100%;" class="selectpicker" multiple data-live-search="true" name="color[]" title="موردی انتخاب نشده">
<option value="" style="color:red;text-decoration-color: red;">قرمز</option>
<option value="" style="color:black;text-decoration-color: black;">مشکی</option>
<option value="" style="color:#aaaaaa;text-decoration-color: aaaaaa;">سفید</option>
</select>

Answer №2

To resolve this issue, one can utilize the Text-decoration property in CSS:

<option class="" style="text-decoration:underline;" value="">Red</option>

Visit Codepen for more details.

Answer №3

try implementing this div {border-width: thin;} include some of these features:-

Measurement | Explanation

medium | Displays a medium border as the standard option
thin | Shows a thin border thick | Indicates a thick border
length | Permits you to specify the thickness of the border. Learn more about length units |
initial| Restores this property to its original value. Read more about initial inherit| Derives this property from its parent element. Find out more about inherit

alternatively, you can utilize this

h1{
  border-style: solid;
  border-width: 15px;
}

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

Confirm the Text Box with JavaScript

I'm struggling with validating the textbox on my login Xhtml. Once I finally cracked the code, I encountered an issue with the 'container' class in the section. How can I properly write the code and successfully validate the textbox? <h ...

changing tooltip color in bootstrap based on the parent element

Is there a way to adjust the bootstrap tooltip background-color based on the container? For example, my header has a white background and my footer is black. #header .tooltip-inner{ background-color:fade(@grayWhite,80); } #footer .tooltip-inner{ backgro ...

An easy way to insert a horizontal line between your text

Currently, I have two text responses from my backend and I'm considering how to format them as shown in the design below. Is it possible to automatically add a horizontal line to separate the texts if there are two or more broadcasts instead of displa ...

Using VB.NET with Selenium to locate and interact with dropdown elements

My knowledge of selenium is limited, and I'm facing difficulty in selecting an element from a dropdown menu on AliExpress using vb.net. The issue arises when the driver either fails to locate the intended element or finds another element with the same ...

Ways to interact with elements lacking an identifier

Currently, I'm faced with an HTML challenge where I need to interact with an element labeled tasks. *<td class="class_popup2_menuitem_caption" unselectable="on" nowrap="">Tasks</td>* In my attempt to do so, I've implemented the foll ...

"the content does not occupy the entire space of the parent

My TableRow expands across the width of the screen, and within it is a ListView with a layout_width set to match_parent. However, the ListView does not expand properly. This issue arose when I added two buttons in the next TableRow. Even after setting the ...

Are you experiencing issues with modal contents extending beyond the modal on smaller screens?

I recently installed a modal plugin called blockUI for my image uploading needs. Although I have styled and positioned everything accordingly, I am facing an issue: Whenever I resize the browser screen, switch to my iPhone, or use another screen, some con ...

Attempting to implement a polygon-shaped button with material-UI and React framework

This is a design I am experimenting with for the poly button above. I have tried various styling methods. Does anyone have any ideas? ...

Identify the occurrence of isolated "<" or ">" characters in a string that includes HTML elements

As an example, consider a string similar to: "This is a <b> Sample </b> string with characters < 100" The user has the ability to include HTML tags such as <b>, <div>, and more. These tags are permitted in this scenario. The ma ...

Adjust the height of the `<input type="file">` element to match the containing div by utilizing Bootstrap 4.5 styling

Can I update the .html file to give the "Choose File" and "Upload" options the same height as the "Upload" button in the second div, which has the py-4 tag? <div class="input-group"> <div class="custom-file py-4"> < ...

Tips for designing a three-line label: positioning text in the middle, above, and below

I have a label that looks like this: https://i.sstatic.net/q0DaR.png Is there a way to position 'Lorem ipsum' perfectly in the center between 'dolor' and 'amet'? https://i.sstatic.net/aJapG.png - reference image T ...

How to set a canvas as the background of a div element

Check out my code snippet below: <!DOCTYPE html> <html> <body> <div id='rect' style='width:200px;height:200px;border:1px solid red'> </div> <canvas id="myCanvas" style="borde ...

Using JQuery to automatically set the default selection when toggling the visibility of a div

I currently have a script that toggles the visibility of a div when selected: $('.showSingle').click(function () { $('.targetDiv').hide(); $('.showSingle').removeClass('greenactive'); $(this).addCla ...

Adjust image size dynamically while keeping the original aspect ratio

Is there a way to scale variable portrait and landscape images dynamically to fit proportionally within a browser window? You can find my current image resizing attempt here: http://jsfiddle.net/6pnCH/4/ I would like the image to be already scaled vertic ...

Aligning a title and a subheading in a horizontal manner

I want to align my h3 headings with my h5, using Bootstrap, so they are on the same line. UPDATE: I aim to leverage existing Bootstrap functionality and avoid modifying CSS unless absolutely necessary. Here is a screenshot illustrating what I mean: https ...

Troubleshooting Bootstrap 4 Content Alignment Issue: Centering Horizontally and Vertically

Having trouble centering my content both vertically and horizontally within the body of the webpage using Bootstrap 4. Despite trying various solutions from the documentation and StackOverflow, I can't seem to get it to work. Would greatly appreciate ...

Reorder the nested list structure

Hello there and thank you for stopping by! I am facing a challenge with a list containing multiple nestings. I am interested in changing the order of these two lists, and I am curious if this is achievable using only CSS. List item 1 List item 2 List ...

Exploring the functionality of v-chips within a v-text-field

I am trying to implement a search text field using vuetify's v-text-field, and I want to display the user input in a chip (such as v-chip or v-combo-box). However, v-text-field does not seem to support chips based on the documentation. Is there a work ...

Drag and drop surprise: When items are dragged onto the screen, a magical box will appear. But watch as the box disappears when the item is dragged

I am a newcomer to knockout JavaScript and am currently utilizing Knockout drag and drop functionality in my project. Initially, I have two divisions - one is visible while the other has a display property set to none. During the drag enter function, I wan ...

What is the functionality of Google Chrome's "New Tab" iframes?

Have you ever wondered about those 8 small iframes displaying your most visited websites? How do they capture snapshots of the websites? How are the websites chosen for display? And most importantly, how do they actually work? Edit: I want to learn how to ...