Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8010211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:40:12+00:00 2026-06-04T18:40:12+00:00

I am using pure CSS to style a < select > drop down box.

  • 0

I am using pure CSS to style a < select > drop down box. Using the code below, I am able to do this with one hiccup: when the text on the option becomes too wide, it doesn’t cut off before the background image of the drop down arrow.

Normal View

When the text is too long:

Text too long

What I would like to accomplish is to have the text cut off before the drop down arrow image so that they do not overlap. However, I would still like the full text to display when the drop down list is expanded:

Expanded

Here is the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Styling Selects</title>
    <style type="text/css">
        .selectDiv select {
            background: transparent;
            width: 250px;
            padding: 7px;
            font-size: 16px;
            border: none;
            height: 34px;
            text-transform: lowercase;
            color: #666666;
            z-index: 100;
            position: absolute;
            left: 0px;
            top: 0px;
        }

        .selectDiv {
            border: 2px solid #666666;
            display: block;
            width: 218px;
            height: 34px;
            overflow: hidden;
            position:relative;
            display: inline-block;
        }

        .selectButtonDiv {
            width: 16px;
            height: 16px;
            z-index: 99;
            position: absolute;
            left: 190px;
            top: 9px;
            display: inline-block;
            background: url("stream_7B0046.png") no-repeat -96px #FFF;
        }       
    </style>
</head>
<body>
    <div class="selectDiv">
        <div class="selectButtonDiv"></div>
        <select>
            <option value="Option 1">Option 1</option>
            <option value="Option With Really Long Name">Option With Really Long Name</option>
        </select>
    </div>
</body>
</html>

Any ideas on how I could trim off the text when displaying the collapsed drop down box but still show the full text when expanded. All this while remaining purely in CSS. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:40:13+00:00Added an answer on June 4, 2026 at 6:40 pm

    My first suggestion would be to make the select wide enough to account for your largest character count. I’m sure you thought of that and it’s not available.

    My second recommendation is adding Javascript, particularly jQuery DD, to replace the select options with definition lists that can be more easily styled. https://github.com/HenrikJoreteg/jquery.dd

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would i create the below using pure CSS (no images, no tables, no
How to create such (see image below) effect using pure HTML JS and CSS?
I want to alternate rowcolor in a GridView, using pure CSS, ie: I don't
I'm trying to write some code using pure SQL using ASP.NET MVC. I assume
I have a pure C++ application developed using VC 6.0. I would like this
I have a pure Actionscript 3 project, using flash.* libraries, compiles down to about
What is the best way (using HTML/CSS) to create an iTunes-style layout with the
I have some server side HTML output I cannot deal with using pure CSS,
I have a triangle next to menu items, using pure CSS. It works flawlessly
I'm trying to create a pure css Venn diagram like this Where the circle

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.