Why is my div section spilling over and disappearing when I switch from desktop to mobile view?

I am struggling to implement a slider on my web application. Despite adding all the necessary code for the slider within a div section with the class slider, I encounter an issue when switching from monitor or landscape view to mobile view - the text in the div section overflows. Here's the HTML code for the slider:

@import url("https://fonts.googleapis.com/css?family=Audiowide|Monoton|Poiret+One|Raleway");

h1 {
  display: block;
  font-size: 3em;
  margin-block-start: 0.67em;
  margin-block-end: 0.67em;
  margin-inline-start: 0px;
  margin-inline-end: 0px;
  font-weight: bold;
}

... // (CSS code continues)

<input {
  display: none;
}
<div class="slider">
    <input name="input-slider" id="input-slide-0" type="radio" class="input-slide input-slide-num" />
    ... // (HTML code continues)
</div>

When the page is in landscape mode, it appears like this:- https://i.sstatic.net/b2ezw.png

However, upon changing to Mobile view, it transforms into something like this:- https://i.sstatic.net/uFXZY.png The text spills out of the div section and spreads everywhere. How can I contain that specific section of the code to stay within the confines of the same section?

Answer №1

Modify the .slider class by changing height: 20vw; to height: 20vh;. Incorporate a media query for mobile screens to set the height of .slider to height: 100vh;, and adjust the font size of both h5 and h1 elements accordingly. Feel free to tweak any other styles as needed.

@media screen and (max-width: 600px) {
  .slider {
   height: 100vh;
   font-size: 1em;
  }
  h5 {
     font-size: 1em;
 }
 h1 {
 font-size: 2em;
 }
}

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

Guide on how to initiate a file download with text area content by clicking an HTML button

I came across this code snippet on GeeksforGeeks, and it partially solves an issue I was facing. <script> function download(file, text) { //creating an invisible element var element = document.createElement('a'); ...

The iframe does not completely fill the col-sm column

https://i.sstatic.net/VeqFj.jpgHaving an issue styling embedded Grafana panels on my website. How can I adjust the iframes to fit within col-sm without large margins (refer to attached screenshot) This is my html: <p class= ...

Guide on concatenating the output values using jQuery

After selecting the matched records from the database, I returned to the previous page. Although I retrieved all the values, I am unsure how to append these return values on this page. What I need is to replace ROOM 2, Room 3... with the value in value.roo ...

Injecting a variety of wallpapers dynamically using css and html

As a beginner in CSS, HTML, and coding in general, I am currently working on creating my own start page with a local path that loads my bookmarks using an HTML file. The background-image control is handled by the style.css file. I have researched ways to c ...

Activate a function once a PHP variable's value has been initialized

To modify an invoice based on the value of invoice_id received from selecting a specific invoice in the invoice list table, the details related to the invoice should be pre-loaded from the database for editing. The code appears as follows: $invoice_id= b ...

Adjustable height for Divs placed between stationary Divs

As a beginner, I have a question that may seem simple to some. I want to create a layout with fixed divs at the top and bottom, but a flexible one in between. To help explain, I've created a sketch. If anyone could provide me with a starting point, I ...

Looking for a quicker loading time? Opt for a shortened version of CSS

Most of the images on my website are optimized using sprite sheets, where multiple images are combined into one file to enhance user experience. This method reduces the number of server requests for individual images. However, I'm facing an issue whe ...

What exactly does '?' symbolize in pagination hyperlinks?

Hey there! I've been diving into a Django book lately and came across a pagination template with a mysterious question mark in the URL. I've looked everywhere but can't seem to find an explanation for it. Check out the template below: < ...

Is it possible to smoothly transition from one background image to another in CSS or JavaScript?

Most tutorials I've come across suggest using a background image with a linear gradient overlay, but that solution doesn't suit my needs: I have two adjacent divs with background images, slightly overlapping by 50px. I wish to create a gradient ...

Looking for assistance with troubleshooting CSS issues specifically in Internet Explorer

Hey there! I've been working on a landing page and it's looking good in Safari, Firefox, and Chrome. The only issue is that the layout is all messed up in IE (any version). If any of you experts could take a look at it and give me some suggesti ...

Caught in an endless cycle while attempting to capture form submissions

My current task involves writing Javascript/JQuery code to intercept form submissions before they are sent in order to validate the fields. However, I am facing an issue where blocking the default event and resubmitting the form triggers an infinite loop b ...

Attempting to establish both the minimum and maximum time date in a jQuery datepicker across two separate inputs

I've been working on a project for my classes that requires setting minimum and maximum dates for two input fields. The first input should allow dates from now to 12 months in the future, while the second input should be restricted to dates picked wit ...

Tips for preventing the direct copying and pasting of JavaScript functions

Repeating the process of copying and pasting functions such as loadInitialValue(), loadInitialValue2(), loadInitialValue3(), is quite monotonous. This is the repetitive code snippet that I have been working on (when you click on "Mark as Read," the title o ...

problem with the picture and wrapper expanding to fill the entire width of the screen

I'm having an issue with the image I added and its hover effect. The image seems to be leaving space on both sides of the screen, even though I've included background-size: cover and width:100% in my code. Could someone please point out where I ...

How can you manage both HTML5 mode routes and hash routes in Angular?

After utilizing the "standard" routes in Angular 1 with the # sign (e.g. /app#/home), I have decided to make the switch to HTML5 mode for cleaner URLs (e.g.: /app/home). I successfully activated HTML5 mode using $locationProvider.html5Mode(true), and ever ...

What is causing the navigation bar on stackoverflow.com to move suddenly when clicked?

Just noticed the sleek new navigation bar on stackoverflow. Reminds me of the bootstrap design I've been using. However, I've encountered a similar issue on my website where the navigation bar jumps slightly when clicked. Does anyone have any su ...

What methods can be utilized to ensure that my wistia video player/playlist is responsive on different devices

I need some assistance with making my Wistia player responsive while using a playlist. I want the video player to adjust its size based on the screen size. Here is an example: My current code utilizes their iframe implementation: <div id="wistia_1n649 ...

Is there a way to align the text input and text area next to each other?

I need help with styling a contact form that consists of 4 text input fields and 1 text area. Here is the current code for the contact form: <form class="contact_form"> <input type="text" placeholder="Name"> <input type="text" plac ...

Changing column layouts on mobile using Bootstrap 4

Using Bootstrap's grid system, I have created a layout with a sidebar. The structure is as follows: <div class="row"> <div class="col-md-3"> ... </div> <div class="col-md-9"> <div class="row"> <div ...

Occupying room while using display: none in <td>

As a newcomer to media queries and .net, I find myself struggling with the code below. At max-width 775px, my goal is to have the first td disappear completely and be replaced by the second td. However, it seems that while the first td becomes 'invisi ...