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

Issues with Google fonts not displaying properly on WordPress site

I'm just starting out with Wordpress and I'm using the html5blank theme to bring in my stylesheets. However, I've run into an issue where the google fonts are not being applied on my wordpress site. In my header.php file, I have included th ...

Adding a disabled internal Style node to the HTML5 DOM: A simple guide

According to this, the style tag can be turned off using the disabled attribute. I attempted the following: <head> <style>body { color: black; }</style> <style disabled>body {color: red; }</style> </head> <bo ...

Troubleshooting directive not functioning properly with AngularJS ng-click

My HTML img tag is not responding to ng-click when clicked. I'm puzzled by this issue occurring in masonryPictureView.html Main page - home.html <ng-masonry> <ng-picture ng-items="projectdescription.pictures"></ng-picture> </n ...

Unable to show <LI> elements

I'm having trouble adding LI items to the #historial <UL> tag. Whenever the for loop is inside the function, the list displays with some elements duplicated. I believe the for loop should remain outside of the function. Could someone please he ...

Trouble arises when trying to link IE7 with jQuery

I am currently testing a website with jQuery. There is a plugin that, when hovered over, slides down to reveal another banner, subsequently sliding the banner below it down as well. I have added a link on the bottom banner using z-index, and although it wo ...

Combine the click event and onkeydown event within a single function

I have a function that sends a message when the Enter key is pressed. However, I also created a button to send a message, but when I call this function, the message doesn't send, even though I added a click event. function inputKeyDown(event, input ...

Having trouble with displaying the results of JQuery Ajax in Chrome?

I am facing a compatibility issue between IE 8 and Chrome 16.0.912.77 with the following code. Any suggestions? <html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(document).ready(fu ...

Choosing a single item from multiple elements in React using React and typescript

In this particular project, React, TypeScript, and ant design have been utilized. Within a specific section of the project, only one box out of three options should be selected. Despite implementing useState and toggle functionalities, all boxes end up bei ...

Is there a way to format a block of text so that right-to-left text aligns to the right, while left-to-right text aligns

I have a content block that includes text in both left-to-right and right-to-left languages, and I need to ensure that both display correctly. If the user begins with left-to-right text, it should be displayed from left to right with left alignment If the ...

Steps for performing a 'back' action within a div element using jQuery

Within my HTML, I have a div element containing a link. When the user clicks this link, I use AJAX to load new content into the div area. This new content includes a 'back' link that, when clicked, should revert back to the previous content. Cur ...

Inject the code snippet from CodePen into a WordPress webpage

I have a WordPress page where I want to integrate the HTML, CSS and JS code from my Codepen project. The styling appears to be working correctly, but the JavaScript is not functioning as expected. You can view the page here: Could someone assist me in pr ...

Divide the output results into two equal horizontal sections within the same HTML table

Is there a way to dynamically split the output of a specific result into two horizontal sections that fit within the browser width? The number of rows returned from the service is variable, so a fixed solution won't work. I also want to avoid manually ...

Tips on updating the arrow icon after clicking on a dropdown menu

HTML: <div class="customSelectContainer"> <ul> <li class="initial">Choose</li> <li data-value="value 1">Option 1</li> <li data-value="value 2">Option 2& ...

Compiling a list of products, but the user interface needs some adjustments

Currently, I have designed a product list menu that includes a hover dropdown feature. This means that when a user hovers over a specific menu item, the corresponding list will automatically appear. However, I am facing two issues with this setup. Firstly, ...

Ways to incorporate ng-app into an HTML element when HTML access is limited

In my current project, I am using Angular.js within a template system. The challenge I am facing is that I need to add ng-app to the html element, but I do not have direct access to do this on the page itself. Initially, my page structure looks like this: ...

Upon clicking the link, my hover function was disabled

Hey everyone, I'm running into an issue on my website where a button is not working as expected. Initially, when I clicked the home page button, it changed the background color like I wanted. However, when I tried clicking it again, the background col ...

Fill the rows of the <Table> using HTML code

I am encountering an issue with displaying data in a table on a screen: <table id="TransactionTable" class="table table-responsive table-striped"> <thead> <tr> <th></th> <th>Date</ ...

What is the right way to efficiently rotate a View in React Native?

Here is my code snippet: <View style={{borderColor:"red",borderWidth:4,flex:1,transform: [{ rotate:'90deg' }]}}> <Text>Hi</Text> </View> The result can be seen here: https://i.sstatic.net/C9ryl.jpg Unf ...

Struggling to align a div in the middle using react and tailwindcss

Struggling to center a div in React with Tailwind, no matter what method I try. Here is my code: "use client"; import Image from "next/image"; import React from "react"; const LoginPage = () => { return ( <div cla ...

Creating an Image Link within Nivo Slider

I have been trying to figure out how to make an image a link in NivoSlider. I know that I can use captions to create a link, but I want the actual image to be clickable for better accessibility. I found a similar question on StackOverflow, but it was rela ...