How can I line up elements in different divs when the width is adjusting based on the window size?

Trying to align a search input and a result element in separate containers when the window size changes. Looking for a solution without using Javascript.

One window size: https://i.sstatic.net/LiQtY.png A smaller window: https://i.sstatic.net/dgj4I.png

Currently utilizing but facing challenges with responsive design. Need guidance on achieving alignment of two elements irrespective of screen width.

My HTML

    <div class="header-section">
    <div class="uk-container uk-container-center uk-text-center">
        <h1 class="uk-h1" id="head1">Search</h1>
        <h1 class="uk-h1" id="head2">Lab</h1>
    </div>
</div>

<div class="input-section">
    <div class ="uk-container uk-container-center uk-text-center">
        <form id="search-form" class="uk-form">
            <input id="search-input" type="text" placeholder="Bing Engine ">
            <button id="search-btn" class="uk-button uk-button-primary" type="button">Search</button>
        </form>
    </div>
</div>

<div class="results-section">
    <div id="results-container" class="uk-container uk-container-center uk-width-1-2">
        <div class="result">
            <a class="result-title" href="#">Bhutan travel advice</a>
            <div class="result-url">https://www.gov.uk/foreign-travel-advice/bhutan</div>
            <p class="result-summary">Latest travel advice for Bhutan including safety and security, entry requirements, travel warnings and health.</p>
        </div>
    </div>
</div>

Looking forward to your feedback!

My CSS: http://pastebin.com/4kkpe8cq

Answer №1

To style elements with CSS:

@media(min-width:800px) {
   // Write your CSS code for a narrow width here
}

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

JSFiddle Functioning Properly, But Documents Are Not Loading

My JSFiddle is functioning properly, but the files on my computer aren't. It seems like there might be an issue with how they are linking up or something that I may have overlooked. I've checked the console for errors, but nothing is popping up. ...

Using Javascript, display an image that was previously hidden with CSS when a radio button is selected

Within a table of 25 rows, each row contains an attribute accompanied by an image (represented by a tick symbol) and five radio buttons for rating the attribute from 1 to 5. Upon clicking one of the radio buttons, the hidden image (tick symbol) should beco ...

Reorganizing Bootstrap 5 columns as the screen size changes

I need to change the display order of columns in bootstrap Currently I have two columns side by side in one row like this: Col A - Col B (on all screens except mobile devices) However, when the screen size is reduced or viewed on a mobile device, I want ...

Maintain Open State of Toggle Drop Down Menu

Having an issue with the toggle down menu or list on my webpage. The problem is that the menu is constantly open (the #text_box) when the page loads. My intention was for it to be closed initially, and then open only when the user clicks on the 'Ope ...

Exploring anchor hover effects and navigating adjacent sibling elements

Consider this html structure: <p><a></a></p> <div><a><img></a></div> To hide all images inside a div after a p tag, you can use the following code: p + div {display:none;} However, attempting to sho ...

Troubleshooting: Bootstrap 5 Alert not Displaying on Website

I'm experiencing an issue trying to display a bootstrap alert in my HTML code. Here is the code I'm using: <div class="alert alert-success alert-dismissible fade show" role="alert"> text & ...

Bootstrap Toggle Button with Dropdown Menu

I have a button-group with font awesome icons and a dropdown on one of them, as illustrated in the example below. I am trying to toggle the button status, but for some reason, the 'active' class is automatically removed on mouseout. It seems to ...

Using rowspan to display JSON data in AngularJS

Unique Json data: [{ cityName: Seattle, population: 1000000, rank: 1 }, { cityName: Portland, population: 800000, rank: 2 }, { cityName: San Francisco, population: 900000, rank: 3 }, { cityName: Los Ange ...

tips for creating dynamic visual effects using CSS on filtered images

img:hover{ -webkit-filter: grayscale(100%); -moz-filter: grayscale(100%); filter: grayscale(100%); } This CSS code snippet will convert the image from color to grayscale upon hovering. However, I am looking to achieve this effect with a smooth animation ...

Material Design Forms in Angular: A Winning Combination

I'm currently working on developing a form using Angular Material. This form allows the user to update their personal information through input fields. I am utilizing "mat-form-field" components for this purpose. However, there are certain fields tha ...

Exploring the methods of connecting with data-checked and data-unchecked attributes in Angular

Utilizing a toggle switch, I am able to determine what text to display in the div by utilizing html attributes such as data-checked and data-unchecked. In addition, I have an Angular pipe that translates all texts on the website based on the selected lang ...

Obtaining only a portion of the text when copying and editing it

I have a React application where I am attempting to copy text from an HTML element, modify it, and then send it back to the user. I have been successful in achieving this, but I am facing an issue where even if I select only a portion of the text, I still ...

Eliminating gaps between elements

I recently delved into the world of web design, and although I have a basic understanding of HTML and CSS, I am determined to enhance my skills and knowledge by creating a standard home page. So far, I managed to create a standard navigation bar, and now ...

Showcasing certain elements as the user scrolls

Looking for a way to display an element (such as a div) when the user scrolls without using JQuery? Here's an example that tries to achieve this: var scroll = document.body.scrollTop; var divLis = document.querySelectorAll("div"); for(let i = 0; i ...

A guide to using Angular to emphasize text based on specific conditions met

Currently, I am developing a testing application that requires users to choose radio type values for each question. The goal is to compare the selected answers with the correct answers stored in a JSON file. To achieve this, I have implemented an if-else ...

Is there a way to make the footer adapt to the varying heights of the grid sections as they grow in size?

Currently, I am facing an issue with the positioning of the page footer. Despite my efforts, it does not remain at the bottom as intended. Please refer to the image for a visual representation of the problem. How can this be rectified? It is worth noting ...

Is there a way to submit a basic HTML form using R?

As a newcomer to R programming, I am excited to apply what I am learning in the Johns Hopkins Data Science track to practical use. My current goal is to automate the process of downloading historical bond prices from the US Treasury website After explorin ...

Having trouble printing webpages? Need a useful tutorial on how to print web pages created using jQuery UI, jqGrid, and Zend?

I have been tasked with printing web pages of a website that utilize jqgrid, Jquery calendar, various Jquery UI components, and background images. The server side is built with Zend Framework. Although I lack experience in web page printing, this has beco ...

Navbar collapse not functioning properly on HTML, CSS, and JavaScript

I have developed a CSS code snippet: .nav{ right: 0px; left: 0px; margin-top: 0px; margin-bottom:20px; height: 35px; text-align: center; background-color: red; z-index: 1; } .sticky { background: #000; text-align: center; ...

Tips for preventing PyCharm from automatically completing HTML and Django template tags

While working on Django templates in PyCharm, I noticed that it automatically closes the tags. This can be helpful when starting a new tag, but it becomes annoying when I want to place existing content within a different tag because I have to delete or mov ...