Styling form fields in Ruby on Rails using Bootstrap

I am looking to style form fields using Boostrap CSS.

Below is the code snippet from my form view file:

<p>
  <%= f.label :country %>
  <%= f.select :country, ["India","USA","Australia"] %>
</p>

I would like the above code to be formatted as:

<select class="form-control">
    <option>India</option>
    <option>USA</option>
    <option>Australia</option>
</select>

I have experimented with different approaches, but without any success.

Answer №1

<%= f.select :country, options_for_select(["India", "USA", "Australia"]), class: "form-control" %>

The expected result will be produced.

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

Allocating the remaining container space to a lone flex item

Imagine a scenario where I have a flex container with children that completely fill the container. .container { display: flex; width: 150px; } .item { flex: 1 1 50px; border: 1px solid blue; } <div class="container"> <div class="item ...

When the open button is clicked, the Div will toggle between open and closed states

Recently, some of my questions have not been well-received, which makes me feel a bit disheartened. It's important to remember to be kind when providing feedback. I've noticed that some people downvote without offering constructive criticism, whi ...

Leveraging font as a comprehensive repository of icons

I have been experimenting with using entypo as the icon source for my web application. The UI technology I am working with is ZK. However, I encountered an issue when trying to include an icon from that font by using: <span sclass="entypoWhite">&am ...

Attempting to consistently place an element at the bottom of my div container

I am attempting to align my <span class="fechar_fancy">Back/span> at the bottom of my div, regardless of the height of my content. I want this element to always be positioned at the bottom. Therefore, I tried using position:absolute and bottom:0 ...

Unwanted extra border and padding are showing up at the bottom of my HTML

Recently, I decided to experiment with the jquery superslide plugin on a website of mine. To my surprise, there was an unexpected padding at the bottom of the page. My suspicion is that the display area is not being calculated correctly or that a margin is ...

Positioning the sDom in jQuery DataTables

Take a look at the image below: I want to adjust the position of the tableTools buttons (Copy, Excel, CSV) so that they appear aligned with the Search Box. I've experimented with different sDom parameters but haven't been successful. This is th ...

Failure to properly register the Stimulus controller that imports chart.js using npm

While working on a rails 7 application that utilizes the chart.js library via npm, I encountered an issue when adding the line: import Chart from "chart.js/auto" inside the stimulus controller. The browser's console displayed the following ...

CSS - sticky header causing issues when resizing the browser window

I'm currently facing an issue with the layout of my navbar. While I've managed to create a fixed navbar that stays at the top, the content on the page seems to be hidden underneath it. To address this problem, I attempted to add a 5% margin from ...

Extracting Div Dimensions Based on Screen Size

I've been racking my brain for the past couple of days trying to solve this. Essentially, I am working on a one-page layout where the first block occupies the entire width and height of the screen, while the second block needs to be relative to the fi ...

Tips for combining grid and flex layout to increase the size of a specific flex item

My dashboard at home consists of various independent components with different design structures. Some are managed using CSS Grid, some using CSS Flexbox, and others as default blocks. I am looking to rearrange these components so they stack on top of eac ...

Issue with the progress bar bouncing back and forth

I am encountering an issue with my progress bar width changing on nav-links click. When I click on each nav-link, the progress bar reaches its width correctly but then turns back and forth unexpectedly. I am unsure why this is happening. Here is the code ...

Unrestricted heading for a spreadsheet

My goal is to create a table with a leftmost header column that has no border, but is still part of the table. In my attempt to achieve this, I used the following HTML code: <table class="my-table" style="border-left: 0"> <tr> < ...

When zoomed in, the div background gives off a crisp white appearance

When I zoom in on a div with a background color or border, it appears completely white. Strangely, this issue doesn't happen when I zoom in on the Facebook site. This picture illustrates the problem more clearly. What could be causing this issue? H ...

Interactive Bootstrap container revealed with hover effect

I'm trying to create a row with 3 blocks (col-md-4) that will "popout" on hover, overlapping the parent container. I've been experimenting but can't quite achieve it while sticking to Bootstrap classes. Any suggestions for how to accomplish ...

disabling certain CSS styles for IE9 specifically

Is there a way to disable certain styles specifically for IE9 while still being able to use transformations in my design? Since IE9 does not support transformations, I am looking to disable them and possibly use jQuery transform() instead. Are there any p ...

A different approach to using Bootstrap 4 instead of shinyBS::popify

My Shiny app incorporates Bootstrap 4 with the help of the bslib package. Unfortunately, the popovers created using shinyBS::popify are not functioning as expected. Is there an alternative method or a solution to make them work properly? library(shiny) l ...

CSS Selector for when a radio button is selected

I'm currently using images in place of radio buttons: <label class="radio-inline thumbs"><input type="radio" id="type_nee" name="type" value="nee" onkeyup="validate()" onclick=" ...

Can the .scroll function be turned off when a user clicks on an anchor link that causes the page to scroll?

I am currently developing a timeline page and I want to implement a feature similar to the chronological list of years displayed on the right side of this webpage: As part of this feature, I have set up a click event which adds a circle border around the ...

What steps do I need to take in order to create a 3D viewer utilizing a Spritesheet

While browsing online, I stumbled upon a Wiki dedicated to the game Team Fortress 2. Initially, it seemed like a typical gaming Wiki, but there was one particular feature that captured my attention and left me completely perplexed. This Wiki showcased all ...

Adding a new div using Jquery after a specific table row

I am having trouble displaying additional data in a table when a specific row is clicked. Here is the table structure I am working with: <div id="display"> <div class="displayRow"> <img src="images/expand-arrow.gif" class="expandArrow ...