When adjusting the browser width to small or extra small for tablets and mobile devices, the content does not properly adjust to fit the screen

body{
background-image: url(https://www.ucalgary.ca/mediacentre/files/mediacentre/aerials_011a7179_fe.jpg);
background-size: cover;
background-repeat: no-repeat;
font-family: 'Numans', sans-serif;
}
html, body{
height: 100%;
}
.container{
height: 100%;
align-content: center;
overflow: hidden;
}
.card{
height: 370px;
margin: 10% auto auto 30%;
width: 450px;
background-color: rgba(0,0,0,0.50);
border-radius: 10px;

}
.card-header h3{
color: white;
text-align: center;
padding-top: 40px;
font-size: 30px;
}
.card-header h4{
color: white;
text-align: center;
padding-top: 50px;
font-size: 20px;
}
.login_btn{
color: black;
background-color: #FFC312;
border-color: #FFC312;
width:100px;
padding: 12px;
border-radius: 5px;
margin-left: 180px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 10px;
font-family: 'Numans', sans-serif;
text-decoration: none;
}
.login_btn:hover{
color:black;
background-color: white;
border-color: white;

.card{
   height: calc(100vh - 20%);
   margin: 10% 15% 0 15%;
}
<!DOCTYPE html>
<html>
<head>
<title>University of Calgary Scholarship</title>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="selectionPage.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">


</head>
<body>
<div class = "container">
<div class="d-flex justify-content-center h-100">
<div class = "card">
<div class ="card-header">
<h3>University of Calgary Scholarship Page</h3>
<h4>Please Select One</h4>
</div>
<div class = "card-body">
<div class = "form-group">
<form action="studentLogin.html">
<input type = "submit" value = "Student" class= "btn float-left login_btn">
</form>
<form action="adminLogin.html">
<input type = "submit" value = "Administrator" class= "btn float-right login_btn">
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

I have made some updates to my code since my last submission, however, I am still facing issues with the content not adjusting properly when the browser window is narrowed down. Particularly, on smaller devices such as tablets or mobile phones, part of the container remains invisible. I tried implementing suggestions provided by another user at the end of my CSS file, which improved the situation but did not completely resolve it, especially at smaller screen sizes.

Thank you for your assistance. .........................................................................

Answer №1

To ensure proper functionality, include the following property:

html, body {
  height: 100%;
}

Check out this fiddle

The image being used is quite large (6144 x 4096 pixels), which may lead to longer loading times. It's recommended to resize it to a maximum width of 2000 px and compress using tools like TinyPng :

UPDATE

You can utilize flex properties for aligning the elements within .card

.d-flex {
  display: flex;
  justify-content: center;
  align-items: center;
}

View this updated fiddle

Answer №2

After reviewing @Vincent G's solution, I have modified the following lines based on your latest comment:

.card{
   height: calc(100vh - 20%);
   margin: 10% 15% 0 15%;
}

Check out the fiddle here

For information on browser support for calc and viewport, click on the links.

UPDATE 1

In the updated version of your code, you can omit the previously mentioned snippet.

You are hindering responsiveness by setting a fixed height for your .card class and making similar errors with your input fields (such as margin-left and width).

To view the changes made in the fiddle, click here.

This adjustment should help resolve your issue :)

Answer №3

Welcome to the world of HTML and CSS coding!

body{
background-image: url(https://www.ucalgary.ca/mediacentre/files/mediacentre/aerials_011a7179_fe.jpg);
background-size: cover;
background-repeat: no-repeat;
font-family: 'Numans', sans-serif;
}
html, body{
height: 100%;
}
.container{
height: 100%;
align-content: center;
overflow: hidden;
}
.card{
height: 370px;
margin: 10% auto ;
width: 450px;
background-color: rgba(0,0,0,0.50);
border-radius: 10px;

}
.card-header h3{
color: #000;
text-align: center;
padding-top: 40px;
font-size: 30px;
}
.card-header h4{
color: #000;
text-align: center;
padding-top: 50px;
font-size: 20px;
}
.login_btn{
color: black;
background-color: #FFC312 !important;
border-color: #FFC312;
padding: 12px;
border-radius: 5px;
margin-left: 0;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 10px;
font-family: 'Numans', sans-serif;
text-decoration: none;
}
.login_btn:hover{
color:black;
background-color: white;
border-color: white;

.card{
   height: calc(100vh - 20%);
   margin: 10% 15% 0 15%;
}
<!DOCTYPE html>
<html>
<head>
<title>University of Calgary Scholarship Page</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>


</head>
<body>
<div class = "container">
<div class="d-flex justify-content-center h-100">
<div class = "card">
<div class ="card-header">
<h3>University of Calgary Scholarship Page</h3>
<h4>Please Select One</h4>
</div>
<div class = "card-body">
<div class = "form-group text-center">
<form action="studentLogin.html">
<input type = "submit" value = "Student" class= "btn login_btn"> <form>

<form action="adminLogin.html">
<input type = "submit" value = "Administrator" class= "btn login_btn">
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

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

JavaScript click event that triggers page scrolling and also executes a separate function

Currently in the process of developing a simple pricing calculator using HTML, CSS, and JavaScript. The user is presented with various questions that can be answered by clicking corresponding buttons for each response. All elements are contained within a s ...

I'm experiencing an issue with my JavaScript clicks not working. Can someone help me troubleshoot

I'm currently working on a shopping cart and trying to figure out why changing quantities is not working as expected. I've created two functions, one for adding quantities and the other for subtraction. My goal is to apply these functions to mult ...

Creating stunning visuals with the power of SVG

I need to create a graphics editor similar to Paint using SVG for a school project. I have JavaScript code for drawing shapes like circles and lines, but when I try to add them to an onClick function for a button, it doesn't seem to be working. funct ...

Can anyone tell me a way to automatically rotate a text or image every 2 seconds?

I've come across a CSS code that enables rotating any text or image by 180% on hover: .card-container { height: 150px; perspective: 600; position: relative; width: 150px; } .card { height: 100%; position: absolute; transform-style: pres ...

How can I place a jumbotron on top of a carousel?

How can I overlay the jumbotron component on top of the carousel in order to create a unique website heading? Any suggestions on what I need to implement to make this happen? ...

What is the process for eliminating the overflow in this situation?

How can I eliminate the overflow issue with this toggle button? The functionality of this toggle button is simple - you click on it to turn it on and off. I've been struggling to find a solution. Every attempt so far has been unsuccessful. All I wa ...

What is the best way to add "m" to the URL for redirecting mobile devices?

Having already installed a mobile detecting plugin for WordPress, my next step is to create a script that can direct users to the mobile version of the site. My idea is to replicate every desktop page on the mobile subdomain and simply add "m" at the begi ...

Problem: Challenge in Iterating and Assigning Variables to HTML Table Elements

I am currently working on a project that involves tracking the order statuses of individual shipments from a list of URLs stored in an Excel sheet. The code I have written is capable of looping through the URLs and extracting information from them successf ...

What is the best way to eliminate the external pause button?

My website contains the following HTML snippet: <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="a ...

Tips for rotating a canvas object without changing its position

I am currently in the process of developing a JavaScript game centered around a character positioned on top of the world. Although the earth element is already part of the game, I am encountering an issue with its rotation causing it to shift position as w ...

Combining Angular and Bootstrap: how to create two overlapping divs

Looking to enhance a project in Angular 15 + bootstrap 5 by creating two draggable divs where the lower one can be vertically resized to overlap the upper one? I've managed to set up most of it, but when dragging the lower div, its transparency makes ...

Ajax: Why am I receiving an error response instead of a successful one?

It's puzzling why my code is triggering the error function instead of success. The console.log keeps showing me this: Object {readyState: 0, getResponseHeader: function, getAllResponseHeaders: function, setRequestHeader: function, overrideMimeType: f ...

Customizing the appearance of the 'Submit' button compared to the <a href=""></a> button using CSS

I am experiencing some issues. Even though the CSS code for these two buttons is exactly the same, their appearance is different. I am unable to make the :hover or :active effects work either. My goal is to have the left 'input type="submit' but ...

html - Datalist showing characters written in Arabic but appearing as squares

My web application functions properly offline and displays Arabic text without any issues, except in datalists where it appears as squares. This issue is specific to Chrome as other browsers do not have this problem. I am currently using the following code ...

Python code using Beautiful Soup to crawl web pages and extract JSON data

Currently exploring the world of beautifulsoup in Python and attempting to extract specific details from a website, particularly the deeplink and title. Utilizing beautifulsoup to gather json data has produced a variable named `soup` of type beautifulsoup ...

Tips on positioning the navbar to the right edge of the screen

Currently using bootstrap, in the process of learning css and bootstrap. Looking to align links within ul to the far right of the screen. Assistance would be greatly appreciated <nav class="navbar navbar-expand-lg navbar-light bg-light"> ...

What issue could be causing trouble with my JavaScript animation?

Currently, I am working on designing a web-page and I have a specific vision in mind - I want an image of the moon to slowly rise up from the bottom of the screen to the top. Here's the HTML code that I have so far: <body> <div id="Moon" ...

Here is a unique variation: "Learn how to duplicate a designated div element from "a.html" and transfer it to "b.html" with

Is there a way to streamline the process of updating a navbar on multiple pages by storing it in a separate HTML file and importing it into all pages using jQuery? This would allow for easy updates to be made once in the distinct file, automatically reflec ...

Generating custom reports based on specific data fields

My current approach involves displaying all the columns for the searched records in a div with the id of searchresults using AJAX. I then provide a print option to print those records. However, I now want to enhance this functionality by allowing users to ...

What are some strategies to prevent a fixed sidebar from obscuring content while zooming in?

I've been working on adding a fixed sidebar for a table of contents (TOC) to a website, where the sidebar stays in place as the user scrolls up and down. My implementation includes the following HTML code: https://i.sstatic.net/jAY8l.png and CSS co ...