Why won't the display: block CSS style apply to my div element?

Take a look at my code:

https://jsfiddle.net/r62p4209/

I created a search bar with company brand name and some buttons on the right, positioned in the center.

My aim is for the search bar (from "search by:" to the "Go!" button) to move onto the next line when the screen width is reduced to 786px. However, my code doesn't seem to be working as expected. Can you help me identify the issue?

Your assistance is greatly appreciated!

Here's the HTML snippet:

<!DOCTYPE html>
<html>
<head>
 <title>test5</title>
 <link rel="stylesheet" type="text/css" href="test5.css">
</head>
<body>

 <div class="center">
 <div class="qwert" id="abc1">
    <a id="Home" href="www.bookavanue.com"><b>Brand</b></a>
 </div>
 <div class="qwert" id="abc3">
    <button id="Register" type="button">Register</button>
    <button id="Login" type="button">Log In</button>
    <button id="Cart" type="button">Cart</button>
 </div>
 <div class="qwert" id="abc2">
    <div id="abcd1">
        <label for="Search">Search by:</label>
            <select value="Title">
                <option>option1</option>
                <option>option2</option>
                <option>option3</option>
            </select>
            <select value="All Books">
                <option>option1</option>
                <option>option2</option>
                <option>option3</option>
            </select> 
    </div>
    <div id="abcd2">
        <input id="Search" type="text" name="Search your book" 
        placeholder="Search Your Books...">
    </div>
    <div id="abcd3">
        <button id="Go" type="Search">Go!</button>
    </div>
</div>
</div>
</body>
</html>

CSS details:

#abc1{
 float: left;
 width: 110px;
}
#abc3{
 float: right;
 width: 185px;
 text-align: right;
}
#abc2{
 display: block;
 width: auto;
}
#abcd1{
 float: left;
 width: 220px;
}
#abcd3{
 float: right;
 width: 40px;
 text-align: right;
}
#abcd2{
 width: calc(100% - 270px);
 display: inline-block;
}
input{
 width: 100%;
}
@media screen and (min-width: 786px){
 #abc2{
    width: calc(100% - 295px);
    display: inline-block;
 }
}

Answer №1

make sure to include the clear:both property ... on your element with the id of abc2, you can see an example in this fiddle

  #abc2.qwert{
    clear:both;
  }

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

Utilizing pseudo elements (after) in CSS with the font family in Font Awesome 6 fails to function properly

I am attempting to create the div using CSS after pseudo-element and I have included the Unicode in the content with the font family being "Font Awesome 6 Free". However, nothing is showing up and I'm not sure why. Can someone please assist me? Here i ...

Saving users' dark mode preference on my website

I recently implemented a dark mode feature on my website. However, I noticed that when I enable dark mode and then refresh the page or navigate away, the preference resets. To address this issue, I am looking to store the user's preference as a cookie ...

Modify the font style of numbers based on the keyboard language selected by the user

Is it possible to change the font family of numbers in input fields based on the user's keyboard language? For example, if the user is typing in Persian, the numbers should be displayed in a Persian font, and when they switch to an English keyboard, t ...

"Enhance user experience with autofocusing on form fields within an overlay

Despite spending hours searching, I can't seem to figure out a seemingly simple task. I am trying to set autofocus on a form field within an overlay that opens when a button is clicked. The overlay is implemented using basic jQuery overlay code. $(f ...

Enable compatibility with high resolution screens and enable zoom functionality

My goal is to ensure my website appears consistent on all screen sizes by default, while still allowing users to zoom in and out freely. However, I've encountered challenges with using percentages or vh/vw units, as they don't scale elements prop ...

Incorporate dc.js into your Cumulocity web application

Our team is facing a challenge while trying to integrate dc.js into our Cumulocity web application. While the standalone version works perfectly, we encounter issues when attempting to use it within Cumulocity. Below is the code for our standalone applica ...

Eliminate any HTML content using Jsoup while retaining the text lines

I am working with a String that contains e-mail content, and my goal is to eliminate all HTML coding from this String. This is the current code I have: public static String html2text(String html) { Document document = Jsoup.parse(html); document = ...

Invisible Thinglink image revealed upon resizing browser

I am currently repurposing a pre-existing theme that has a drop-down menu showcasing an image. I am attempting to integrate a Thinglink into the content section of this drop-down, but unfortunately, the image does not appear until I adjust the size of the ...

Conceal a particular row in SharePoint by utilizing JavaScript with jQuery

I'm facing an issue with SharePoint 2010 where the _cts folder is visible in all document libraries. Despite my efforts to research and find a solution, I have been unsuccessful so far. For now, my workaround is to hide the entire row. Here's a ...

What is the best way to access the inner html of every cell within a table row that I have selected?

I want to implement a feature on my website where users can click a "save" button on a specific row in a table and save the entire row's innerHtml onto another page as their favorite hiking trails. I've been trying to achieve this by adding clic ...

.value not showing correct data in JavaScript

I am attempting to retrieve the value entered by the user in an HTML input field. While I can display a fixed, predetermined value with ease, this is not my intention. My goal is for users to input a numerical value and for that value to be displayed/adj ...

Target the first element within a tree structure using CSS

Trying to target the initial blockquote in an email body with varying formats, such as: <div class="myclass"> <br><p></p> <div><div> <!--sometimes with less or more div--> <blockquote&g ...

Add a new class to an element located in a separate div using JavaScript

$(document).ready(function() { $('.btn').click(function() { $(this).parent().addClass('show'); }); }) <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div clas ...

Automatically transferring CSS class attributes to a newly created class

The Issue I've encountered a problem while developing a small app for a website. The form in the app requires validation, but conflicts with existing jQuery scripts have been causing errors. These conflicting styles are essential to maintain the desi ...

Arrange the table by column following a service request

Is there a method to organize the table below once it has been loaded? I am utilizing Google API to retrieve distance matrix data, but I want the table to be sorted by distance. However, this sorting should take place after the Google service call is comp ...

In a React application, the input field unexpectedly loses focus after typing just one character

Has anyone encountered an issue with a dropdown menu causing input field focus to be lost after typing one character? I've attempted setting unique keys for each field, but it hasn't resolved the problem. For reference, here is the link to the p ...

Tips on how to transform an <input type="text"> element into a <tr> element using jquery

I am currently working on updating a row using jQuery Ajax. Whenever the Edit button is clicked, it switches the <tr> element to <input type='text'>. I have utilized the .Change method which triggers successfully, but my goal is to r ...

Adjust the background color of the dropdown menu

I'm struggling to change the background color of the property address picker dropdown from transparent to white. I've been trying different things but can't seem to get it right. Any suggestions? Additionally, I want to change the cursor to ...

Utilize a Dropdown Menu to Retrieve Information from a Database and Display the Results on Either the Current Page or a Separate Page

My PHP page includes a code snippet that generates an HTML table: <table> <thead> <tr> <th class="wheniwant">Date</th> <th class="wheniwant">Income Amount</th> <t ...

Trimmed scrollbar and border in Webkit

There seems to be some clipping on the scrollbar and border of the textarea: <!DOCTYPE html> <html> <head> <meta charset="UTF-8> <title>Scrollbar and Border Clipping Issue in Webkit</title> <style> ...