Tips for creating a page that adjusts smoothly to every screen size and resolution

I'm new to web design and need some help. I'm trying to display a search box on a webpage. It looks fine at 100% resolution, but when I increase the screen resolution, it moves and the content gets out of place. Here is the original image of my search box:

and this is after zooming in using ctrl+ + :

1: https://i.sstatic.net/KrexC.pngenter code here

This is the code for my search box:

    <!--start SearchBox section-->
    <center>
        <section id="searchbox" style="background:white">
            <div class="container" style="margin-top:0px;">
             <div class="row">
                <div class="col-lg-12">

               <form >
                    <center>
                            <div id="SearchBoxBorder" style="background:white;border:none;border-radius:5px;margin-top:20px;width:800px;">
                            <table id="mytable" >
                                    <td style="width:300px;background:white;">
                                       <center> <div class="form-group">
                                                <input type="text" class="form-control" id="searchtopicTxt" placeholder="I am looking for">
                                        </div></center>
                                     </td>

                                     <td style="width:50px;text-align:right;background:white;"> <center><strong>in</strong></center>    </td>

                                     <td style="width:400px;background:white;">
                                     <center>
                                             <div class="input-group" style="position:relative;">
                                                   <input type="text" class="form-control" placeholder="this locality" id="searchLocalityTxt">
                                                   <div class="input-group-btn">
                                                            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" 
                                                            id="dropdownBtn">Select<span class="caret"></span></button>

                                                             <div class="SearchCities" id="dialog" title="Basic dialog">

                                                                            <div id="outer_div" style="">
                                                                                        ...
                        

And here is the CSS for the search box:

    table#mytable
    {
    width:100%;

    }
strong { font-size:28px; margin:0px 20px 0 0px; height:30px; line-height:30px; color:#333333; }

.SearchCities {

      position:absolute;
      margin-top:1px;
      top:100%;
      right:134px;
      z-index:1;

    }

#dropdownBtn{
     background:white;border-top-width:5px;border-right-width:5px;border-bottom-width:5px;border-left-width:1px;border-color:#eee;height:42px;border-radius:0px;text-align:center;color:black; margin-right:20px;margin-top:2px;
}

...

I've noticed that the output differs when I view the same page in Mozilla and Chrome. I want it to be responsive to any resolution without varying outputs across browsers. Any suggestions or solutions would be appreciated. Thank you in advance.

Answer №1

When it comes to creating a responsive layout, you have a couple of options:

1. You can set heights and widths using %
2. Utilize media queries for more dynamic responsiveness

You can learn more about media queries here

For further guidance, check out this resource on Responsive Web Design

Answer №2

Customize the styling

  1. All dimensions are specified using max-width.

  2. Additionally, they are set in percentages rather than pixels.

For instance:

.SearchCities
{
    max-width:20%;
    max-height:10%;
}
  1. Alternatively, you can opt for a new theme, such as Wordpress 2013 that is responsive. Wordpress

Answer №3

To achieve responsive design, make use of CSS media queries.

For a comprehensive understanding of CSS media queries, check out this insightful resource.

Further clarity on the topic can be found by exploring the following link:

http://www.w3.org/TR/css3-mediaqueries/#media0

I hope this information is beneficial to you.

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

Store the position of a draggable object using JQuery into an SQL database

Because of the current crisis, my friends and I are unable to meet up in person. To stay connected, I've come up with a little game for us to play online. Each of us can move an object on my website, and when the page is refreshed, we'll see the ...

Deactivate a chosen anchor button when clicked within a loop of elements

In my laravel project, I have a foreachloop that is rendering multiple buttons. I want to disable or remove only the button that is clicked, so I tried the following code: @foreach() <a onclick="remvebtn()" class="btn">My ...

Insert an HTML page into a div element

I am having an issue with my angular template. I have a div where I am attempting to load an HTML view file (.html) based on a $watch event, but for some reason, the HTML view is not being loaded into the div. Below is a snippet of my controller code that ...

What causes the presence of a boundary around the svg?

I have been encountering an issue while attempting to incorporate my logo into the header of my webpage. Specifically, when viewed on smaller screens, I noticed that there is a margin surrounding the SVG image. Below is my HTML file: <html lang="e ...

The link that has been clicked on should remain in an active state

Is there a way to make the link that is clicked on active? I have attempted various scripts but have had no luck in getting the desired effect. Can anyone identify what might be causing the issue? $("a").click(function () { if ($(this).hasClass("acti ...

The vertical-align property in CSS fails to function properly when applied to specific rows or columns within the

Hello, I have been experimenting with table attributes and came across the valign attribute. However, I encountered some cells that were not affected by it. So, I decided to try CSS vertical-align instead. To my surprise, some cells were affected while oth ...

The image link may be broken, but rest assured the file is still in its

Having an issue with two domains that point to the same site folder. One image is loading correctly, but the main image link seems to be broken. Both image files are located in the exact same folder and the img src is a relative link, so it should be funct ...

Is it possible to create a dynamic drop-down list in PHP using an array?

In the image above, a new row will be added when the user clicks on the [add more] button. While this functionality works perfectly, I would like to send these values using AJAX. I am able to access all textbox values with the array map function in AJAX ex ...

Align three divs vertically within one div, all floated to achieve the desired layout

Can someone help me align three divs vertically within a container div? The challenge is that all three divs inside the container are floated - one on the right, one in the center, and one on the left to create a navbar. I've seen the navbars in Boot ...

Looking for the answer to utilize selenium for product scraping

I'm currently focused on a personal project involving parsing product names and prices. To achieve this, you can navigate to shoppingSite. After arriving at the site, click the button below the map, then click it again on the right side. Opt for the u ...

Using MVC3/Razor to trigger an Ajax request to the Controller

I am working on a Razor view that includes multiple dropdown lists. My goal is to have the ability to clear the values in one dropdown when the value in another dropdown is changed, and then populate it with new values based on the model being used by the ...

Transforming a string into an object

I've been working on this code where my aim is to convert a string into an object and then display the data from an ajax call. However, it appears that using the string value in this way is not functioning as expected. var string = "first: 'Geor ...

Discovering a location on Google Maps using a postal code in a particular country

In the past, I used a method that involved adding a postal code to the end of a Google Maps link to view a specific location. For example, if the postal code is 649414, I would add it to the following link: https://www.google.com/maps?q=649414. However, I ...

React modal image showing a misaligned image upon clicking

I recently integrated the react-modal-image library into my project to display images in a modal when clicked. However, I encountered an issue where the displayed image is off center with most of it appearing offscreen. I'm unsure what is causing this ...

The preflight response does not allow the access-control-request-methods request header field due to restrictions set in the access-control-allow-

I'm facing CORS issues while trying to make a POST request from my website to a remote server. Despite searching online, I couldn't find a solution that fits my specific problem. Below are the parameters for my ajax request: var params = { ...

Changing flexbox positioning for 3 divs on mobile screens

Is it possible to align 3 divs differently based on screen width using Bootstrap flexbox classes? For example, I want them to align like the top image below on small widths (<576px) and like the bottom image below on larger widths (>576px). https:// ...

Cypress: A guide to storing CSS color values in a variable

I'm struggling to figure out how to save a CSS color value to a variable using Cypress in my React application. I have a good understanding of the assertions, such as: cy.get('myElement').should('have.css', 'color').and ...

Retrieving JSON data without using Jquery's Ajax function

I was wondering if there is any way to retrieve the results of a jQuery AJAX call and store them in a traditional variable for use as a function. Here's an example: function getPoints(){ //An array of JSON objects var Points; ...

Manipulate an image with PHP and jQuery to rotate it, then store the edited image in a specified destination directory

This is not just a question, but an opportunity to share knowledge with many like-minded individuals. After spending hours working on rotating images dynamically using PHP and jQuery, I have come up with a solution that I believe will benefit others in the ...

Using a for-loop to add HTML Ids sequentially

I'm a beginner in JavaScript and HTML, and I've been working on reading my JSON file and appending it to various HTML IDs. I was curious if there is a more efficient way of doing this using a for-loop? for(let i=0; i<5; i++){ $(`#vid${i ...