Issue
I'd like the 'Go' button to stay next to the search field. On Desktop view it looks fine but when I switch to a mobile view it wraps the submit button (the input-group gets broken up). how do I prevent that?
Also, bootstrap is adding gray lines around the form when in mobile, if anyone knows how to prevent that I'd live to know.
I tried 'flex-nowrap' from the docs but it's for a different version of Bootstrap, I think. It didn't work. https://getbootstrap.com/docs/4.3/components/input-group/#wrapping
<body>
{% block navbar %} <!-- Nav Bar -->
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<a style="font-size: 20px; padding-top: 16px;" class="navbar-brand" href="{{ url_for('index') }}">My Website</a>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#main-menu" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
{% if base['search_bar'] %}
<div class="navbar-form navbar-left col-lg-6">
<div class="input-group">
<form method="POST" action="{{ url_for('search') }}">
{{ base['search_bar'].hidden_tag() }}
{{ base['search_bar'].search_for(class="form-control", placeholder="Search with Barcode") }}
<span class="input-group-btn">
{{ base['search_bar'].start_search(class="btn btn-primary") }}
</span>
</form>
</div><!-- /input-group -->
</div><!-- /.col-lg-6 -->
{% endif %}
<div id="main-menu" class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
{% if current_user.is_anonymous %}
<li><a href="{{ url_for('login') }}"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
<li><a href="{{ url_for('signup') }}">Register</a></li>
{% else %}
<li><a href="{{ url_for('index') }}"><span class="glyphicon glyphicon-user"></span> {{ current_user.username }}</a></li>
<li><a href="{{ url_for('logout') }}"><span class="glyphicon glyphicon-log-in"></span> Logout</a></li>
{% endif %}
</ul>
</div>
</div>
</nav>
{% endblock %} <!-- Nav Bar -->
class SearchBar(FlaskForm):
search_for = StringField('Search', validators=[DataRequired()])
start_search = SubmitField('Go')
This is how it looks for mobile users.
Solution
Basically place them in the same .input-group
div. You can use bootstrap's 3 markup syntax.
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
<body>
{% block navbar %}
<!-- Nav Bar -->
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<a style="font-size: 20px; padding-top: 16px;" class="navbar-brand" href="{{ url_for('index') }}">My Website</a>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#main-menu" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
{% if base['search_bar'] %}
<div class="navbar-form navbar-left col-lg-6">
<div class="input-group">
<form method="POST" action="{{ url_for('search') }}">
<div class="input-group">
<input type="search" class="form-control" placeholder="Search with Barcode">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
</div>
</form>
</div>
<!-- /input-group -->
</div>
<!-- /.col-lg-6 -->
{% endif %}
<div id="main-menu" class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
{% if current_user.is_anonymous %}
<li><a href="{{ url_for('login') }}"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
<li><a href="{{ url_for('signup') }}">Register</a></li>
{% else %}
<li><a href="{{ url_for('index') }}"><span class="glyphicon glyphicon-user"></span> {{ current_user.username }}</a></li>
<li><a href="{{ url_for('logout') }}"><span class="glyphicon glyphicon-log-in"></span> Logout</a></li>
{% endif %}
</ul>
</div>
</div>
</nav>
Answered By - IT goldman
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.