Reputation: 7145
<div align="center" class="form-group">
<select v-model="subject" class="form-control">
<option v-for="n in papertypes" class="">{{ n.type }}</option>
</select>
<br>
Bootstrap takes the full width for the select drop down by default. I want it to be set to get the width what it requires. How do I achieve this?
Upvotes: 1
Views: 6561
Reputation: 4633
You can make it possible by giving width for that specific class like
<div align="center" class="form-group">
<select v-model="subject" class="form-control">
<option v-for="n in papertypes">{{ n.type }}</option>
</select>
</div>
.form-group select.form-control {
display: inline-block;
width: 300px;
}
Check the codepen link
Also please notet align
attribute is deprecated in HTML5. So if you want to align the content to center. Bootstrap has classes for that. Like text-center
in Bootstrap3, we have justify-content-center
in Bootstrap4.
Upvotes: 3
Reputation: 544
you can add "custom-select" class for select.
<div align="center" class="form-group">
<select v-model="subject" class="custom-select">
<option v-for="n in papertypes" class="">{{ n.type }}</option>
</select>
Upvotes: 0
Reputation: 34107
Add the class w-auto
to .form-control
<div align="center" class="form-group">
<select v-model="subject" class="form-control w-auto">
<option v-for="n in papertypes" class="">{{ n.type }}</option>
</select>
<br>
Upvotes: 1