Adaptable dropdown menu

I am currently utilizing unsemantic.css for my web layout. Here is a basic structure I have set up:

<div class="grid-container">
  <div class="grid-65">
    Insert content here
  </div>

  <div class="grid-35">
    <select>
      <option value="0">First option</option>
      <option value="1">Second option</option>
    </select>
  </div>
</div>

My goal is to make the select box width be equal to its parent div (35% of a grid row). The default width of this element is determined by the length of its options.

I attempted the following code:

select {
  width: 100%;
}

However, this did not have any effect overall. When I manually set the width to a specific value like 500px, it works fine but is not responsive.

Answer №1

Greetings Matěj Štágl, it seems like the issue lies in the select element being set as inline-block by default. To resolve this and make it responsive, you can simply change its display property to block and set its width to 100%. Feel free to refer to the code snippet below for assistance.

    select{
     display: block;
     width: 100%;
    }

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

Difficulty with implementing CSS Sprites in a jQuery-driven menu

Facing issues with a code base that was previously owned by someone else. Deadline is approaching fast and struggling to solve a particular issue. This code includes a table in the top section of the page, featuring a drop-down menu using CSS sprites for ...

Unique CSS animations that vary before and after

Looking to enhance a navbar with some interactive effects: Upon hovering over an item, I want it to disappear and be replaced by the same text in a different color. After the initial animation, I'm interested in adding another effect like a 360-degr ...

What could be causing the unexpected white space at the top of the webpage, right above the navigation bar?

Take a look at the code provided on this link: I attempted to address the issue by removing the Scroll Bar in CSS, assuming it was caused by overflow-x. However, the blank space above the navigation bar persists. Upon inspecting the page using the Browser ...

Incorporating Masonry-inspired images into a website's design section

I have been working on incorporating a masonry layout of images into my website, but I am facing alignment issues. The images are simply stacking on top of each other instead of creating the desired masonry effect. Are there any tips on how to create a mas ...

Utilizing AngularJS to dynamically apply CSS classes based on the $index value

Is there a way to style my div based on the ng-repeat index, applying different styles for odd and even rows? The row with an even index should have all classes specified for the odd one plus additional classes. Controller: var odd = { 'class1&apos ...

Hidden Div on Google Maps no longer concealing

Since early December, the Google map on my site has been working perfectly. However, the other night, I noticed that the map now defaults to open when entering the site and cannot be closed. Strangely, all my Google maps are behaving this way even though n ...

Tips for reordering the Bootstrap 4 navbar items

I'm in need of assistance on how to reposition the Bootstrap 4 Navbar. Currently, the logo is on the left side, but I would like it to be centered with menus on both sides. Can someone guide me through this process? <nav class="navbar navbar-li ...

The slideshow fails to show correctly after being loaded from an external JavaScript file

Utilizing standard code, I have set up a Slideshow at the top of a website: HTML: <body id="Top" onload="showSlides()"> ... <div id="slides"> <div id="slide1" class="slides fade"></div> <div id="s ...

Is it possible to animate CSS Grid components?

Is it possible to animate a re-ordered set of elements in an array that are arranged using a CSS Grid layout? Check out this quick boilerplate ...

If the URL hash matches the ID of a specific div, then take action on the div's child element

Imagine I have the following HTML structure: <div class=".blog-item-holder"> <div id="AAAA"><div class="inner">AAAA</div></div> <div id="BBBB"><div class="inner">BBBB</div></div> <div id="CCCC">& ...

Leveraging the power of AJAX, PHP, and JavaScript to display numerous status updates throughout an extended operation

It has come to my understanding that when using PHP, it is not feasible to send messages to the DOM using AJAX as the entire script must finish executing before the response becomes available. This leaves me with two possible solutions: Break down the le ...

Implementing hover effect triggered by keyboard input

Is there a way to create a hover effect on a div when a specific key is pressed on the keyboard using jQuery? <div id="d-up" class="button"></div> Appreciate any help with this! Thank you. ...

Struggling with Bootstrap's responsive design: Ensuring images remain anchored at the bottom of a div

I recently integrated the Bootstrap product example into my website, located at https://getbootstrap.com/docs/5.0/examples/product/. Everything works well except for a minor issue I encountered on iPads or when zooming in on computers - the images on the w ...

No JavaScript needed for this CSS framework

I have been tasked with creating a website without the use of JavaScript, following very specific instructions. Furthermore, it must be compatible with iPhone and other mobile devices, while still adhering to the no JavaScript rule. I am open to utilizing ...

"Line Divider Makeover: A Guide to Realignment and Focus

Looking to center a line divider on my webpage, I came across a method using this link: http://jsfiddle.net/gtKBs/1133/ However, I couldn't figure out how to change the straight line into a dotted one through coding. That's why I'm seeking ...

What is the best way to modify this CSS code for use in a React Native

Encountering an issue while trying to apply this CSS property in a React Native project. border-radius: 50% / 100%; Attempting the following: borderRadius: '50% / 100%' An error message is displayed stating "Java.lang.string cannot be cast to ...

Using shadow effects on the <Grid> component with Material UI

Is there a way to implement the box-shadow property on a <Grid> component in Material UI? I've gone through the official documentation regarding Shadows - Material UI, but I'm struggling to grasp how it can be applied to a <Grid>. De ...

Generate an angled border for a div

Is there a way to create a slanted div using CSS without relying on borders, especially when the div will be placed over an image? Here is what I have so far: <div class="thumbnail"> <a href="#"> <img class="img-responsive" src= ...

The background image fails to appear on the webpage's body

Having an issue with my CSS not displaying correctly. I am new to coding in HTML and CSS and need help getting the image to display full screen. Despite trying everything, it is still not working. body { background-image: "/folder/photo.gif"; } I hope ...

Sliding Toggle: Panel Revealed with Button Slide

Currently, I am working on implementing a jquery slide tab feature. The functionality is working fine on button click. However, I want the button to stick with the panel and slide along with it. At the moment, the button remains fixed while the panel slide ...