Issues arising with the functionality of CSS media queries when used in conjunction with the

I created a webpage that is functioning well and responsive on its own. However, when I integrate the same files with the Spring framework, the responsiveness of the webpage seems to be lost.

To ensure the responsiveness of the Spring webpage, I tested it by opening the page on mobile devices and using Chrome's inspect mode.

If you require more details, feel free to ask.

HTML File


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ page isELIgnored="false"%>


<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">

<title>URL Shortner</title>
<link href="https://fonts.googleapis.com/css?family=Poppins" rel="stylesheet" />
<link type="text/css" rel="stylesheet"
href="${pageContext.request.contextPath}/resources/css/style.css" />
</head>
<body>



<div class="s130">

<form:form action="show" method="POST" onsubmit=" return continueornot();">
  <h1>Short URL </h1>
  <p>Paste your Long URL here</p>
    <div class="inner-form">
        <div class="input-field first-wrap">
        <div class="svg-wrapper">
          
        </div>
            <input class="input-tag" id="search" type="text" name="longUrl" placeholder="Paste your Link here!" />
        </div>
        <div class="input-field second-wrap">
            <input class="btn lco" type="submit" value="Search" />
        </div>
    </div>
     <span id="error"></span>
    <h2 id="urlerror">${link}</h2>
</form:form>
<footer>
</footer>


</div>

<script>
function validateEmail(email) { 
var re = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
return re.test(email);
} 
function continueornot() {
if(validateEmail(document.getElementById('search').value)){
// ok
}else{  urlerror.innerHTML = "<span style='color: red;'>"+
"Please enter a valid URL!</span>"
return false;}
}
</script>

</body>
</html>

MY CSS


body{
    background: linear-gradient(to right, #fbfbfb, #cfc0c0);
    color: #ffffff;
}

.container{
margin-left:20px;
}
h1{
    font-size: 70px;
    text-align: center;
    margin-top: 8%;
    margin-bottom: 5%;
    color: #1f1f1f;
    font-family: "montserrat";
}

h2{
    font-size: 50px;
    text-align: center;
    margin-top: 2%;
    margin-bottom: 5%;
    color: #ffffff;
    font-family: "montserrat";
}

span{
    color: #1f1f1f;
    font-size: 400;
    font-weight: 900;
}

p{
    text-align: center;
    margin-top: -30px;
    font-size: 18px;
    letter-spacing: 3px;
}



.btn{
margin: auto;
    display: block;
    background-color: transparent;
    border: 2px solid #1f1f1f;
    border-radius: 0.6em;
    color: #1f1f1f;
    font-size: 1rem;
    font-weight: 400;
    padding: 1.2em 2.5em;
    cursor: grab;
    text-align: center;
    text-transform: uppercase;
    font-family: "montserrat";
    font-weight: 900;
}

.btn:hover{
    color:#ffffff;
    outline: 0;
}

.lco{
    transition: box-shadow 300ms ease-in-out, color 300ms ease-in-out;
}

.lco:hover{
    box-shadow: 0 0 40px 40px #1f1f1f inset;
}

.input-tag{
    display: block;
    margin : 20px auto;
    padding: 10px;
    border: 0;
    border-radius:15px;
    width:50%;
    height:25px;
    font-size: 20px;
    font-family:inherit;
    box-shadow:0 0 15px 4px rgba(0,0,0,0.06);
}

@media screen and (max-width: 600px){
    h1{
        font-size: 40px;
        text-align: center;
        margin-top: 12%;
        margin-bottom: 12%;
        color: #1f1f1f;
        font-family: "montserrat";
    }
    p{
        text-align: center;
        margin-top: 40%;
       
        font-size: 14px;
        letter-spacing: 1px;
        color: #1f1f1f;
    }
    h2{
        font-size: 25px;
        text-align: center;
        margin-top: 8%;
        margin-bottom: 5%;
        color: #1f1f1f;
        font-family: "montserrat";
    }
    .btn{
        background-color: transparent;
        margin-top: 7%;
        border: 2px solid #1f1f1f;
        border-radius: 0.6em;
        color: #1f1f1f;
        font-size: 1rem;
        font-weight: 200;
        padding: 0.5em 1.5em;
        cursor: grab;
        text-align: center;
        text-transform: uppercase;
        font-family: "montserrat";
        font-weight: 500;
    }
    .input-tag{
        display: block;
        margin : 0px auto;
        margin-top: 10%;
        padding: 10px;
        border: 0;
        border-radius:15px;
        width:70%;
        height:24px;
        font-size: 14px;
        font-family:inherit;
        text-align: center;
        box-shadow:0 0 15px 4px rgba(0,0,0,0.06);
    }
   
}

Project structure:

Answer №1

If you want to implement @media queries in your Spring Boot CSS file, it is recommended to use min-width instead of max-width for better results.

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

Is jQuery causing the table to exceed the page width?

I have a table in my HTML document that is displaying too many columns in a single row (~25), causing the table to stretch beyond the size of the page and creating unwanted scrollbars. I am seeking a solution to shrink the content of each column while also ...

Setting the initial position for an SVG path

Working on a unique loading animation with 3 shapes that will scale as they follow a path. Each shape begins from a different starting point but follows a similar path. Shapes and paths were created in Illustrator and exported as SVGs. See below for an exa ...

Issues with DnD functionality in Chrome, images not visible during dragging operation

At first, I encountered an issue with event.dataTransfer.setDragImage not functioning properly in Chrome. This can be seen in the example below: http://www.tutorialspoint.com/cgi-bin/practice.cgi?file=html5-59.htm Upon further investigation, I noticed th ...

Tips on automatically centering an image within a div as it is resized

I'm currently working on a website that showcases cards featuring Discord users. Each card includes an avatar image within a div element, and when the user hovers over it, the image expands. However, I've noticed that as it expands, it shifts to ...

Steps for creating a sleek vertical slider with transitional effects using JavaScript and HTML

Take a look at my code snippet: <table> <tr> <td onclick="shownav()">Equations of Circle <div id="myDownnav" class="sidenav"> <a>General Info</a> <a>In Pola ...

Setting the position of a tooltip relative to an element using CSS/JS

I'm struggling to make something work and would appreciate your help. I have a nested list of items that includes simple hrefs as well as links that should trigger a copy-to-clipboard function and display a success message in a span element afterwards ...

Activate the overflow feature within native-base cards

I have a unique design element on a website that showcases an image overflowing off a card. The image has a negative margin-top of -50, creating this effect. Now I'm trying to replicate this design in react-native using native-base components. Here i ...

Trouble with the div element's change event

Hey there! I'm having trouble with this jQuery code that is supposed to fade in or fade out a div based on its contents. Here is the HTML code: <div class="mainContentWrapper"> sample text </div> And here is the CSS code: div.main ...

Limiting click event to only Image component in Next.js

Is there a way to trigger a click event only on the image itself, rather than the entire parent div? When setting width and height for the parent div, the click event seems to encompass the entire area. For instance, if the image is 600 pixels wide by 300 ...

Unable to save the ID of an element into a jQuery variable

I am currently working on a project that involves an unordered list with anchor tags within it. I am trying to access the id of the li element that is being hovered over, but for some reason, the alert is returning undefined or nothing at all. Here is the ...

The <form> element is giving me headaches in my JavaScript code

Trying to troubleshoot why my HTML pages render twice when I add a form with JavaScript. It seems like the page displays once with the script and again without it. Below is the basic HTML code: <form action="test.php" method="post"> <div class=" ...

Positioning the icon within the input field

I am facing a couple of challenges. I have chosen to utilize focus and blur for text values in input fields instead of placeholder text due to an issue in Chrome where the placeholder text is centered. My goal is to position the icon in the input field, p ...

Tips for dynamically altering the @Test method within TestNG

I am currently facing a challenge with designing my test automation framework, specifically regarding incorporating TestNG and reporting/logging. My framework is built using Selenium, where I retrieve data (method names) from an excel file. Within my main ...

What is causing React Js to fail loading css when switching from anchor tag to link tag?

I am learning React and experimenting with creating a basic static website using HTML templates in version ^18.2.0 of React JS. Everything seems to be functioning correctly, however, I have encountered an issue with page refresh. Specifically, when I repla ...

What is the best way to ensure that my multiple choice code in CSS & JS only allows for the selection of one option at a time? Currently, I am able

I'm currently facing a small issue that I believe has a simple solution. My knowledge of Javascript is limited, but I am eager to improve my skills in coding for more visually appealing websites. My problem lies in the code snippet below, where I am ...

The hamburger menu in Bootstrap collapses along with the navigation items when viewed on a mobile device

How can I resolve the issue of the hamburger menu icon collapsing with the nav-items when clicked? Navbar <header> <div class="container-fluid"> <div class="row"> <div class="col-12 col-sm-12"> ...

The Eclipse Debugger fails to halt at a conditional breakpoint

I am currently debugging Java code in Eclipse and I need some assistance. Here is the code : public Double repulsion(Node n1, Node n2) { Double rep = 0.0; rep = Math.pow(K, 2) / distEuc(n1, n2); System.out.println("Répulsion : " + rep); ...

Blending HTML elements with ASP.NET code

Trying to concatenate two strings separated by a line break. This snippet shows what I am attempting: <td>@(string.Join("<br /> ", report.TimeReportProjects.Select(x => x.Project.ProjectName)))</td> <td>@(string.Join("<br /& ...

Recover Checkmark Status from Data

Currently, I am storing form data in json format and encountering an issue when trying to load values from a previously created json file. The plain old JavaScript function provided below successfully loads values into a form from a file, effectively resto ...

What are the best methods for adjusting the tempo of MIDI files with varying resolutions?

In my Java Swing MIDI editor app, I have implemented a feature that allows users to set the playback tempo in quarter beats per minute. The program can play back music with varying resolutions ranging from 24 to 1000 ticks per quarter note. However, for hi ...