Bootstrap 4 - how to set the width of navbar item (select box)
I'd like to add a drop-down list to the navbar and can't figure out how to make it wider. Here is what I actually have:
<nav class="navbar navbar-expand-lg navbar navbar-dark bg-dark">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarTogglerDemo01">
<a class="navbar-brand" href="#">Hidden brand</a>
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
</ul>
<nav class="navbar-nav mx-auto">
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
<option value="looooong">VeeeeeeeryLooooongVeeehicle</option>
</select>
</nav>
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu ml-auto" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#">Action-1</a>
<a class="dropdown-item" href="#">Action-2</a>
<a class="dropdown-item" href="#">Action-3</a>
</div>
</li>
</ul>
</div>
</nav>
Any ideas ? Thank you.
bootstrap-4
add a comment |
I'd like to add a drop-down list to the navbar and can't figure out how to make it wider. Here is what I actually have:
<nav class="navbar navbar-expand-lg navbar navbar-dark bg-dark">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarTogglerDemo01">
<a class="navbar-brand" href="#">Hidden brand</a>
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
</ul>
<nav class="navbar-nav mx-auto">
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
<option value="looooong">VeeeeeeeryLooooongVeeehicle</option>
</select>
</nav>
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu ml-auto" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#">Action-1</a>
<a class="dropdown-item" href="#">Action-2</a>
<a class="dropdown-item" href="#">Action-3</a>
</div>
</li>
</ul>
</div>
</nav>
Any ideas ? Thank you.
bootstrap-4
Do you mean the select or thedropdown-menu
?
– Zim
Nov 21 '18 at 16:46
I meantselect
item displaying cars.
– belgoros
Nov 21 '18 at 16:52
Finally, it seems like the select item adapts itself to the longest item it contains.
– belgoros
Nov 21 '18 at 16:53
Yes, it does.. so how wide are you trying to make it?
– Zim
Nov 21 '18 at 17:08
I’d like it to be centered and take 1/3 of the space between the brand name and the very right-end element of the navbar.
– belgoros
Nov 21 '18 at 17:48
add a comment |
I'd like to add a drop-down list to the navbar and can't figure out how to make it wider. Here is what I actually have:
<nav class="navbar navbar-expand-lg navbar navbar-dark bg-dark">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarTogglerDemo01">
<a class="navbar-brand" href="#">Hidden brand</a>
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
</ul>
<nav class="navbar-nav mx-auto">
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
<option value="looooong">VeeeeeeeryLooooongVeeehicle</option>
</select>
</nav>
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu ml-auto" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#">Action-1</a>
<a class="dropdown-item" href="#">Action-2</a>
<a class="dropdown-item" href="#">Action-3</a>
</div>
</li>
</ul>
</div>
</nav>
Any ideas ? Thank you.
bootstrap-4
I'd like to add a drop-down list to the navbar and can't figure out how to make it wider. Here is what I actually have:
<nav class="navbar navbar-expand-lg navbar navbar-dark bg-dark">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarTogglerDemo01">
<a class="navbar-brand" href="#">Hidden brand</a>
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
</ul>
<nav class="navbar-nav mx-auto">
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
<option value="looooong">VeeeeeeeryLooooongVeeehicle</option>
</select>
</nav>
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu ml-auto" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#">Action-1</a>
<a class="dropdown-item" href="#">Action-2</a>
<a class="dropdown-item" href="#">Action-3</a>
</div>
</li>
</ul>
</div>
</nav>
Any ideas ? Thank you.
bootstrap-4
bootstrap-4
edited Nov 21 '18 at 16:40
belgoros
asked Nov 21 '18 at 15:59
belgorosbelgoros
1,59821018
1,59821018
Do you mean the select or thedropdown-menu
?
– Zim
Nov 21 '18 at 16:46
I meantselect
item displaying cars.
– belgoros
Nov 21 '18 at 16:52
Finally, it seems like the select item adapts itself to the longest item it contains.
– belgoros
Nov 21 '18 at 16:53
Yes, it does.. so how wide are you trying to make it?
– Zim
Nov 21 '18 at 17:08
I’d like it to be centered and take 1/3 of the space between the brand name and the very right-end element of the navbar.
– belgoros
Nov 21 '18 at 17:48
add a comment |
Do you mean the select or thedropdown-menu
?
– Zim
Nov 21 '18 at 16:46
I meantselect
item displaying cars.
– belgoros
Nov 21 '18 at 16:52
Finally, it seems like the select item adapts itself to the longest item it contains.
– belgoros
Nov 21 '18 at 16:53
Yes, it does.. so how wide are you trying to make it?
– Zim
Nov 21 '18 at 17:08
I’d like it to be centered and take 1/3 of the space between the brand name and the very right-end element of the navbar.
– belgoros
Nov 21 '18 at 17:48
Do you mean the select or the
dropdown-menu
?– Zim
Nov 21 '18 at 16:46
Do you mean the select or the
dropdown-menu
?– Zim
Nov 21 '18 at 16:46
I meant
select
item displaying cars.– belgoros
Nov 21 '18 at 16:52
I meant
select
item displaying cars.– belgoros
Nov 21 '18 at 16:52
Finally, it seems like the select item adapts itself to the longest item it contains.
– belgoros
Nov 21 '18 at 16:53
Finally, it seems like the select item adapts itself to the longest item it contains.
– belgoros
Nov 21 '18 at 16:53
Yes, it does.. so how wide are you trying to make it?
– Zim
Nov 21 '18 at 17:08
Yes, it does.. so how wide are you trying to make it?
– Zim
Nov 21 '18 at 17:08
I’d like it to be centered and take 1/3 of the space between the brand name and the very right-end element of the navbar.
– belgoros
Nov 21 '18 at 17:48
I’d like it to be centered and take 1/3 of the space between the brand name and the very right-end element of the navbar.
– belgoros
Nov 21 '18 at 17:48
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53415948%2fbootstrap-4-how-to-set-the-width-of-navbar-item-select-box%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53415948%2fbootstrap-4-how-to-set-the-width-of-navbar-item-select-box%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Do you mean the select or the
dropdown-menu
?– Zim
Nov 21 '18 at 16:46
I meant
select
item displaying cars.– belgoros
Nov 21 '18 at 16:52
Finally, it seems like the select item adapts itself to the longest item it contains.
– belgoros
Nov 21 '18 at 16:53
Yes, it does.. so how wide are you trying to make it?
– Zim
Nov 21 '18 at 17:08
I’d like it to be centered and take 1/3 of the space between the brand name and the very right-end element of the navbar.
– belgoros
Nov 21 '18 at 17:48