Element within Bootstrap is not in a hidden state

For Small Devices(sm) size, I want a hidden search box with a search button instead. This is how I want my search to look like in small devices: view image here

This is the code I have:

    <div class="container">
        <div class="header">
            <div class="row">
                <div class="col-md-3 ">
                    <img src="img/1.png" class="header-logo" alt="site-logo">
                </div>
                <div class="col-md-6">
                    <div class="input-group search-box">
                        <div class="input-group-prepend">
                            <span class="input-group-text">
                                <i class="fas fa-search"></i>
                            </span>
                        </div>
                        <input type="text" class="form-control" placeholder="Search">
                    </div>
                </div>

                <div class="col-md-3 btn-header">
                    <button class="btn">Login</button>
                    <button class="btn">Sign Up</button>
                </div>
            </div>

</div><!-- =====HEADER DIV===== -->
    </div>

Answer №1

Utilize

hidden-sm

To learn more, visit https://getbootstrap.com/docs/3.3/css/

            <div class="input-group search-box">
                    <div class="input-group-prepend">
                        <span class="input-group-text">
                            <i class="fas fa-search"></i>
                        </span>
                    </div>
                    <!-- your search field is hidden in the sm -->
                    <input type="text" class="form-control hidden-sm" placeholder="Search">
                </div>

Devices list

  • Extra small devices - Phones (<768px)
  • Small devices - Tablets (≥768px)
  • Medium devices -Desktops (≥992px)
  • Large devices -Desktops (≥1200px)

Answer №2

If you want to control the visibility of elements using Bootstrap, you need to utilize the display utilities. For instance, if you wish to display something only on Small Devices, you can achieve this by using d-none d-block d-sm-none.

Here is an example of how your code could look:

 <div class="container">
        <div class="header">
            <div class="row">
                <div class="col-md-3 ">
                    <img src="img/1.png" class="header-logo" alt="site-logo">
                </div>
                <div class="col-md-6 d-none d-md-block">
                    <div class="input-group search-box">
                        <div class="input-group-prepend">
                            <span class="input-group-text">
                                <i class="fas fa-search"></i>
                            </span>
                        </div>
                        <input type="text" class="form-control" placeholder="جستجو">
                    </div>
                </div>

                <div class="col-md-3 btn-header d-sm-none">
                    <button class="btn">ورود</button>
                    <button class="btn">ثبت نام</button>
                </div>
            </div>

</div><!-- =====HEADER DIV===== -->
    </div>

More information on Bootstrap's display utilities can be found in the documentation here: https://getbootstrap.com/docs/4.0/utilities/display/

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

What techniques can I employ in HTML and CSS to design the user interface for my Java application?

Recently, I came across an interesting article at this link: http://docs.oracle.com/javafx/2/webview/jfxpub-webview.htm. The article demonstrates how to develop a java application utilizing the javafx library and utilizing classes like WebEngine and WebVie ...

How to verify in HTML with Angular whether a variable is undefined

When it comes to the book's ISBN, there are instances where it may not be defined. In those cases, a placeholder image will be loaded. src="http://covers.openlibrary.org/b/isbn/{{book.isbn[0]}}-L.jpg?default=false" ...

Revealing elements with AngularJS ng-show directive prior to concealing them

Currently, I am in the process of implementing a slide effect for bootstrap badges to showcase hierarchical data relationships using AngularJS. My goal is to have a slider-effect that smoothly reveals new sub-categories while concealing previously open su ...

including extra information beside a <ul> unordered list

I have a list of product specifications that I need to display in a spec sheet format. Here is the code I have so far: <div class="productspec"> <ul> <li>Product Description</li> <li>Device Type</li> <li>Bundled ...

Can a horizontal line and an icon be perfectly aligned in a single row?

I'm having trouble getting an image to align in a single line with the <hr>. Is there another method besides using position? ...

FireFox supports JavaScript functionality, whereas Chrome and IE do not execute JavaScript code

Here is a snippet of my code where I am creating a div with a dropdown box on my webpage. I would like to trigger an onClick event when an element in the select box is selected: $("div.projectTeamTools").html('Organize by Project Teams: <select id ...

Modify the styling of the main webpage using the iframe

Can the CSS of a parent page be modified from an iframe when the parent page and iframe are hosted on separate domains? ...

Error loading CSS file on Google App Engine

I attempted to add a CSS file as a static file in my project just to experiment with how it functions, but encountered difficulties right from the start. The content of the CSS file is: body { background:#00FF00; } In addition, here is my configurat ...

Is there a method to determine the total of values contained within an HTML table under designated headers? - IONIC

Details: My html table has 2 columns labeled as Debit and Credit, each with respective numbers listed below them. Goal: I am looking to calculate the sum of the numbers under both Debit and Credit. Please check out the about page in the repository for ...

Is Html.Raw necessary for handling ragged html generated by Razor?

When it comes to generating HTML in a dynamic grid model using Razor, the following code snippet is often used: @{ int blockCounter = 0;} @foreach (var item in Model.Items) { if (blockCounter++ % 3 == 0) { //ragged html open here, when needed ...

I am having trouble grasping the concept of how the find method operates in

I am new to using jquery. I have created a table in HTML below: https://i.sstatic.net/6Odg3.png My goal was to display three alert boxes consecutively for 3 checkboxes found in my table. Here is the code I used: $(document).ready(function(){ $("#but ...

Tips for customizing a bootstrap CSS file or incorporating it into your project

Embarking on a new journey into web development, I found myself diving deep into the realms of the internet to edit a template for a forum website. It's certainly a challenge, given my limited experience in this field. The template utilizes a bootstr ...

What is the best way to attach multiple files in PHP using mail.php and mime.php from Pear library?

I am having trouble attaching multiple files. When I try to attach more than one file, only one file gets sent in the email even though I attached multiple files. if(isset($_POST['upload'])){ include('config.php'); include_once ...

Tips for effectively resizing plotly charts in RMarkdown HTML reports

I'm having trouble incorporating plotly graphs created by timetk functions into my rmarkdown HTML notebook. I don't understand why these plots shrink in width in the HTML document while they look fine in the rmarkdown source editor. To adjust th ...

Showing a notification that is persistent and not dismissible

Hello everyone! I've been struggling with a problem on the RPS project for quite some time now. The issue arises when I try to display a message for a tie in the game, but I can't seem to find a solution to make it disappear when the round is not ...

What steps should I follow to make a dynamic carousel card with Bootstrap that adjusts to different screen sizes

My goal was to design a Bootstrap card with an embedded 'slideshow'. The idea was to use the second page to provide more information about the content on the first page. While editing this on the web, I managed to create a satisfactory product () ...

Enhancing User Experience: Use of Multiple Select Radio Buttons in Conjunction with Jquery UI Tabs and Mals

Whenever I select one radio button, I want all other radio buttons in each form with the same value to also change. I've been having trouble getting this functionality to work, so I created a JSFiddle for you to review here. Any assistance would be g ...

Tips on how to dynamically allocate an id value to a jQuery function that retrieves the backgroundImage URL

I have a div with a background image and I am using a jQuery function to retrieve the URL of the background image. var name=image; var url=$("#"+name+"").css("background-image"); console.log(url); <script src="https://cdnjs.cloudflare.com/aj ...

Enhanced HTML table using Bootstrap with a plethora of additional elements

I know this might sound like a silly question, but I've been struggling to create an HTML table that has the following requirements: https://i.sstatic.net/FiRSD.jpg Additionally, I want the table to be hover sensitive so that when you place your curs ...

Variability of pixel dimensions on various devices

When it comes to front-end design in CSS, the use of pixels as a measurement is quite common. However, with varying display sizes and resolutions, one might wonder how relevant this fixed pixel size really is. Is there a way to utilize real-world measure ...