Enhance the user experience by adding visual appeal to the first option in the selection form. Make it

Is there a way to change the color of the first option in the selection box to grey, similar to the example above?

Additionally, how can I create a clickable icon that will display all options? The current setup is not functioning correctly.

<div class="form__group form__group-selection">
    <label for="location" class="form__label"><i class="fas fa-map-marker-alt"></i></label>
    <select name="location" id="location" class="form__select">
        <option class="form__select-option" value="selected" selected>Select one option</option>
        <option class="form__select-option" value="polska">Polska</option>
        <option class="form__select-option" value="lotwa">Łotwa </option>
        <option class="form__select-option" value="estonia">Estonia</option>
        <option class="form__select-option" value="anglia">Anglia</option>
        <option class="form__select-option" value="czopki">Czopki</option>
    </select>
</div>

Link: https://codepen.io/direct96/pen/zJbpPZ - Codepen

Answer №1

I have made updates to the jsFiddle platform. It is important to note that I have also modified the HTML section, as it seems necessary to include the "disabled" attribute (and subsequently, you will need to add the "selected" attribute as well).

<script type="text/javascript>
    function changeMe(sel)
    {
      sel.style.color = "#000";              
    }
</script>
$header-text-color: #efefef;
$form-bgn-color: #f6f6f6;
... (CSS code continues) 
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  ... (HTML code continues)

Answer №2

To change the appearance of the "Select one option" to grey, simply add the "disabled" attribute to the option. As for your query about adding a clickable icon to display all options, there isn't a straightforward solution for that. It may require some JavaScript, but compatibility with all browsers is uncertain.

html {
  font-size: 65.2%;
}

*,
*::before,
*::after {
  box-sizing: inherit;
  margin: 0;
  padding: 0;
}

body {
  box-sizing: border-box;
  font-family: "Lato", sans-serif;
  font-size: 1.6rem;
}

.container {
  height: 100%;
  background-image: linear-gradient(to top, #c5eff3 15%, #f59f4d 70%, #bc2029 100%);
}

.form__header {
  padding: 2rem;
  text-align: center;
  color: #efefef;
  letter-spacing: 0.1rem;
  text-shadow: 1px 2px 3px black;
}
.form__box {
  background-color: #f6f6f6;
  padding: 30px;
  width: 70%;
  margin: 0 auto;
  position: relative;
}
.form__box::after {
  content: "";
  position: absolute;
  left: -1rem;
  right: -1rem;
  top: -1rem;
  bottom: -1rem;
  border: 1rem solid rgba(0, 0, 0, 0.2);
}
.form__group {
  border: #c5c5c5 1px solid;
  border-radius: 3px;
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
}
.form__group:not(:last-child) {
  margin-bottom: 2rem;
}
.form__group-selection::before {
  font-family: "Font Awesome 5 Free";
  font-weight: 900;
  content: "\f0d7";
  font-size: 2.5rem;
  color: #c5c5c5;
  position: absolute;
  top: 50%;
  right: 2%;
  transform: translateY(-50%);
}
.form__label i {
  font-size: 2rem;
  color: #c5c5c5;
  padding: 1rem 1.5rem;
  position: relative;
}
.form__label i::after {
  content: "";
  position: absolute;
  top: 15%;
  right: -1px;
  height: 75%;
  border-right: solid 1px #c5c5c5;
}
.form__input-text {
  width: 100%;
  padding: 0.5rem 2rem;
  background-color: #f6f6f6;
  border: 0px;
  font-family: inherit;
  font-size: 1.4rem;
  transition: all 0.3s ease-out;
}
.form__input-text::placeholder {
  color: #c5c5c5;
}
.form__input-text:focus {
  outline: none;
  border: #6ba81a 2px solid;
  z-index: 1;
}
.form__select {
  -webkit-appearance: none;
  width: 100%;
  padding: 0.5rem 2rem;
  background-color: #f6f6f6;
  border: 0px;
  font-family: inherit;
  font-size: 1.4rem;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link rel="stylesheet" href="css/style.css">

  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU"
    crossorigin="anonymous">
  <link href="https://fonts.googleapis.com/css?family=Lato:400,700,900" rel="stylesheet">

  <title>Forms</title>
</head>

<body>
  <div class="container">

    <div class="form">
      <h1 class="form__header">
        Register Form
      </h1>

      <form action="" class="form__box">
        <div class="form__group">
          <label for="username" class="form__label"><i class="fas fa-user-alt"></i></label>
          <input type="text" id="username" placeholder="Username" class="form__input-text" required>
        </div>
        <div class="form__group">
          <label for="password" class="form__label"><i class="fas fa-lock"></i></label>
          <input type="password" id="password" placeholder="Password" class="form__input-text" required>
        </div>
        <div class="form__group">
          <label for="password-repeat" class="form__label"><i class="fas fa-lock"></i></label>
          <input type="password" id="password-repeat" placeholder="Confirm Password" class="form__input-text" required>
        </div>
        <div class="form__group">
          <label for="email" class="form__label"><i class="fas fa-envelope"></i></label>
          <input type="email" id="email" placeholder="Email" class="form__input-text" required>
        </div>
        <div class="form__group form__group-selection">
          <label for="location" class="form__label"><i class="fas fa-map-marker-alt"></i></label>
          <select name="location" id="location" class="form__select">
            <option class="form__select-option" value="selected" selected disabled>Select one option</option>
            <option class="form__select-option" value="polska">Polska</option>
            <option class="form__select-option" value="lotwa">Łotwa </option>
            <option class="form__select-option" value="estonia">Estonia</option>
            <option class="form__select-option" value="anglia">Anglia</option>
            <option class="form__select-option" value="czopki">Czopki</option>
          </select>
        </div>
      </form>

    </div>

    <div style="height: 5000px;"></div>
  </div>
</body>

</html>

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

JavaScript: Can you clarify the value of this variable using five sets of double quotations?

Could you please review the code snippet below for me? <script type="text/javascript"> function recentpostslist(json) { document.write('<ul class="recommended">'); var i; var j; for (i = 0; i < json.feed.entry.length; i++) { ...

Issue with jQuery: addClass not toggling within an IF statement

Is there a way to dynamically add the class "disable" to an anchor tag when a user selects the radio button labeled "Remove"? Currently, in the provided fiddle, the class is added as soon as the page loads. I have included code in the script that successf ...

Searching for a solution on how to effectively utilize ng-repeat to filter data based on a specific field when passing an array, while considering that the field may or may not be included in the array. Working within Angular

ng-repeat="equipment in equipments | filter: {guidEquiment: ['cb8b22e1-43f0-4dc9-b2dc-34847731e2d1','cb8b22e1-43f0-4dc9-b2dc-34847731e2d1','cb8b22e1-43f0-4dc9-b2dc-34847731e2d1',....N]}" When the variable equipment has a guid ...

Transferring data between pages using HTML5 and jQuery

I'm currently developing Windows Phone 8 apps using HTML5 and jQuery. My project involves two HTML pages - the first page consists of input boxes and a button, while the second page contains controls to display the data entered on the first page. Upon ...

"Enhancing User Experience with Multiple Conditional Checkboxes in jQuery

Having difficulty making a checkbox change some HTML content using JQuery. There is a standard html checkbox with the following attributes <input type="checkbox" name="AQN1" class="checkbox Q1" value="AQN10" id="3mcq"> <input type="checkbox" nam ...

What is the functionality of the disabled attribute on an option tag within a dropdown select menu?

I am working with a code snippet that involves understanding how the attribute:disabled functions on an <option> within a <select> element! Let's say I have a dropdown for ratings and I select the 5-star option (★★★★★). Upon sel ...

The custom component at the beginning of the MDX file in a Next.js project is not adhering to the

My nextjs project is running on the following versions: "@mdx-js/loader": "^2.1.5", "@mdx-js/react": "^2.1.5", "@next/mdx": "^12.1.6", "next": "^12.1.6", Within my project, I ...

What methods can I use to visually distinguish external links from those on my website?

Can CSS be used to show users which links are external? ...

Exploring HTML and CSS backgrounds

I am new to CSS and I have a question regarding design. I want to create a form in the center of my webpage (shown as the black box) with a white background that overlaps the body background (represented by the red lines). For reference, please view this ...

Is it HTML True or False in the editor?

For the HTML template I'm working on, I want to implement a feature where users can toggle tags on and off easily. My idea is to make it as simple as setting a value to "true" or "false." Is there a way to achieve this within a single HTML file? ...

Is there a way to execute a Python script when submitting an HTML form?

I have created an HTML form and my goal is to utilize Python to transfer the data from this form into an SQLite database file. Currently, I am attempting to achieve this using CGI. I don't require anything extravagant. Below is the code that I am work ...

Adding hue to the portion of text following a JavaScript split() operation

I need assistance in printing the text entered in a textarea with different colors. I am separating the string using the split() method, which works fine. However, I now want to print the substrings in the textarea with colors. How can this be achieved? & ...

html code abruptly halted due to an unexpected termination of the file

I'm experiencing an issue with my senaraiperalatanstaf.php file. I inserted some PHP code in between, but now I'm getting a parse error indicating an unexpected end of the file. I've tried troubleshooting it without success. Any help would b ...

Changing the width of an HTML table does not produce any noticeable results

I attempted to create a striped table with 5 columns. The desired column sizes are: 10% width --- 10% width --- 40% width --- 20% width --- 20% width However, my current code is not achieving the correct widths (the 'description' column does n ...

Emphasizing a full row within a table is a way to draw attention

I have a piece of HTML/CSS code that successfully underlines the text in a single table cell when hovering over it. However, I want to extend this effect to underline all text in a row of cells, rather than just one cell. It's not necessary for the en ...

What is causing concatenated string class names to fail in Tailwind CSS?

Whenever I find myself needing to style my React elements, I end up using the style attribute instead of className. None of the examples I've come across seem to apply styles that fit my specific needs. Can you shed some light on why this happens and ...

Icon toggling menu bug

I recently designed a menu featuring an animated icon that, when clicked, opens with two columns. The issue I'm facing is that after clicking on a link in the right column (view JSFiddle), the menu disappears but requires two additional clicks on the ...

Include a navigation bar in the footer of my WordPress Theme's footer.php file

Looking for help with adding a custom footer to my WordPress theme. I have successfully uploaded my static website here, and now I am in the process of making it dynamic. I have added my primary menu to WordPress, but I am unsure of how to exactly add a fo ...

Utilizing jQuery to effortlessly generate parent and child elements in a single function call

Is it possible to create multiple elements with the same function? Currently, I am able to split a number of list items like this: <ul class="dropdown-menu"> <li>Stuff</li> <li>Stuff</li> <li>Stuff</li> ...

The newly added highlighted CSS in jQuery cannot be removed once an alert is generated

http://jsfiddle.net/Cyjye/ I am a beginner with jquery. I have created an HTML table shown in the jsfiddle link. Initially, the selection should be made from the second row, second cell, but in my HTML table, the selection is being made from the first ro ...