Concealing the HTML button on a mobile display

On my website, I have a button that leads users to the next section of the page. I am trying to hide this button in mobile view but I am struggling to find the correct CSS code to do so.

Check out the JSFIDDLE for the code:

https://jsfiddle.net/cgqme8xo/1/#&togetherjs=qTV1soRSqs

This is the HTML code snippet:

<section>
<a href="#main" class="scroll-down" address="true" class="text-right hidden-md"></a>
</section>

And here is the CSS used:

.scroll-down {
  opacity: 1;
  -webkit-transition: all .5s ease-in 3s;
  transition: all .5s ease-in 3s;
}

.scroll-down {
  position: absolute;
  bottom: 30px;
  left: 50%;
  margin-left: -16px;
  display: block;
  width: 32px;
  height: 32px;
  border: 2px solid #EF4043;
  background-size: 14px auto;
  border-radius: 50%;
  z-index: 2;
  -webkit-animation: bounce 2s infinite 2s;
  animation: bounce 2s infinite 2s;
  -webkit-transition: all .2s ease-in;
  transition: all .2s ease-in;
}


.scroll-down:before {
    position: absolute;
    top: calc(50% - 8px);
    left: calc(50% - 6px);
    transform: rotate(-45deg);
    display: block;
    width: 12px;
    height: 12px;
    content: "";
    border: 2px solid #EF4043;
    border-width: 0px 0 2px 2px;
}

Answer №1

When working with Bootstrap 3, you had the option to utilize Bootstrap's Responsive Utilities in this manner:

<section >
    <a href="#main" class="scroll-down text-right hidden-xs" address="true"></a>
</section>

However, with Bootstrap 4, utilizing Responsive Utilities involves slight changes:

<section >
    <a href="#main" class="scroll-down text-right hidden-xs-down" address="true"></a>
</section>

Answer №2

Here is a simple solution:

@media (max-width: 600px) {
  .scroll-down {
    display: none;
  }
}

You can adjust the width to hide the button according to your needs.

For a demonstration, you can check out the updated fiddle by clicking here: https://jsfiddle.net/cgqme8xo/2/. Just resize the visible area and see how it shows or hides the button accordingly.

Answer №3

@media screen and (max-width: 460px) {
  .scroll-down{
    display: none;
  }
}
@media screen and (min-width: 461px) {
  .scroll-down{
    display: block;
  }
}

What do you think about utilizing @media screen instead?

Answer №4

If you're already using Bootstrap, there's a way to achieve the desired result without the need for custom CSS. Here's how:

<section class="hidden-lg-up">
  <a href="#top" class="scroll-to-top" address="true" class="pull-right"></a>
</section>

Simply replace hidden-lg-up with the appropriate breakpoint and display property that aligns with your specific requirements. Refer to Bootstrap's documentation for a complete list of available options.

Answer №5

To implement a responsive design in CSS, you need to use a @media query.

Begin by adding a viewport <meta> tag within the <head> section of your HTML:

<head>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

Next, apply the @media query in your CSS stylesheet like this:

@media only screen and (max-width: 768px) {
  .scroll-down {
    display: none;
  }
}

You can customize the value of max-width: 768px according to your design requirements. This rule will take precedence over other CSS styles when the screen width is less than the specified amount.

Test the responsiveness by resizing your browser window.

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

Verify that all images retrieved through AJAX have finished loading before proceeding

Is there a way to ensure all images in the HTML loaded via AJAX are fully loaded before performing an action like displaying them? I've experimented with various methods, including using the 'imagesloaded' plugin. var page = 'P40&apos ...

Scrolling in iOS 8 causing flickering problem with background image

Utilizing the Supersized jQuery slider plugin to create a full-page background slider with a fade-in effect and added height for scrolling. The slider functions correctly on desktop, but upon testing on an iOS 8 iPad device, there is noticeable flickering ...

Exploring the differences between the meta viewport and font size

My website includes the following code in the section: <meta name="viewport" content="width=990"/> This setting helps to display my webpage well on mobile devices, as using width=device-width causes issues with elements that have 100% width. Howeve ...

The Struggle with Bootstrap Accordion

I'm currently in the process of learning bootstrap. I copied the code for the 'Flush' Accordion from the bootstrap docs, but my version looks completely off. Despite linking the CSS stylesheet and JS Bundle, it doesn't seem to align pro ...

div table with varying cell styles on each row

Is it feasible to achieve a table layout resembling the one depicted below using only div tags and CSS? _________________________________________________ | | | | | | | | ...

Tips for updating a div element while maintaining its style and select2 plugin functionality with jQuery

Within the HTML code, I am attempting to refresh the following div: <select name="test[]" id="test" multiple required class="select2"> @foreach($tests as $s) ...

Difficulty with JQuery Show and Hide Functionality

I've implemented a jQuery menu, but encountering the issue where clicking on any menu link opens all menus instead of just the one clicked. I've attempted to resolve this by using show and hide classes, however, it seems that nothing is working n ...

How can I adjust the font size of information retrieved from a JSON file using ng2-smart-table?

I recently tried using the following CSS code: :host /deep/ ng2-smart-table {font-size:22px;} However, despite implementing this code, I have not noticed any change in the font size. ...

Adding an additional stroke to a Material-UI Circular Progress component involves customizing the styling properties

I am attempting to create a circular progress bar with a determinate value using Material-UI, similar to the example shown in this circular progress image. However, the following code does not display the additional circle as the background: <CircularP ...

Help with dynamically updating page content using JSON

As I work on enhancing my website, I am focused on making the recipes pages dynamic. I have set up a JSON test database and developed a JS file that retrieves values from the JSON file to display them within appropriate divs on the page. My goal is to ena ...

Utilizing jQuery to add a class to an element when a different one is hovered above

I'm currently working on implementing effects on the edges of a webpage that will be triggered when a central div is hovered over. The main tool I'm using for this task is jQuery. Despite my efforts to diagnose the issue by using alerts in my Ja ...

What could be causing my span element to not show up on my header?

How can I add (mock) buttons to my page using just CSS? I've been trying to display a span element but it's not showing up. I've experimented with setting its display to block and positioning it absolutely, but so far nothing has worked. Whi ...

Looking for assistance with aligning UL elements in CSS using absolute positioning for a dropdown effect

I'm currently working on implementing a language switching feature on this website. The concept involves using a SPAN element that reveals a dropdown box (based on UL) containing a list of available languages when hovered over. Below is a preview of t ...

Creating a div that reaches the bottom of a scrollable webpage in ASP

Struggling to position my sidebar at the bottom of the page without using fixed positioning, as I don't want the buttons to scroll along with it. I simply want the background to extend to the bottom of the scrollable page. Despite trying various "solu ...

How can I shift a DIV to be 200 pixels left of the center?

I am trying to position a DIV element 200 pixels to the left of center. My current code is as follows, but I have noticed that on higher resolution screens (such as 1920x1080), the DIV tends to shift out of its intended position: .hsonuc { position: ...

Pattern for identifying Google Earth links with regular expressions

I'm attempting to create a regular expression that can validate whether the URL entered by a user in a form is a valid Google Earth URL. For example: https://earth.google.com/web/@18.2209311,-63.06963893,-0.67163554a,2356.53661597d,34.99999967y,358.13 ...

Is it possible to send a form without using a submit button or pressing the enter key?

Is it possible to submit the value of a <select> in a PHP form without using a submit button? In my HTML/PHP code, I have two forms with two <select> elements. The second <select> (sub category) should use the value selected in the firs ...

Send image data in base64 format to server using AJAX to save

My goal is to store a base64 image on a php server using the webcam-easy library (https://github.com/bensonruan/webcam-easy). I added a button to the index.html file of the demo: <button id="upload" onClick="postData()" style=" ...

Ensuring the alignment of the vertical centers of icons and text within the .row class

Having some trouble with the basics again, but this time I'm stuck trying to figure out how to align an icon and "Feature 1" at the top and center of the page, as shown in the image (with the cyan lines), followed by a random paragraph. <body> ...

CSS3 Transform can sometimes cause unpredictable z-index or depth arrangements

Could there possibly be a glitch in CSS3, or am I just making a simple mistake? Take a look at the page I'm currently working on: View Page I wish I could demonstrate the error, but its behavior seems to be completely unpredictable. Here's what ...