Tips for maintaining button alignment consistently horizontal on desktop devices, except when viewed on a mobile phone

On my larger monitor, the buttons are positioned in a row with three in line and the fourth one below. I would like to arrange them horizontally on desktop but stack them vertically on mobile devices. Is this possible?

<!DOCTYPE html>
<html>
<link rel="shortcut icon" href="https://upload.wikimedia.org/wikipedia/commons/thumb/5/5e/Metro-M.svg/2000px-Metro-M.svg.png">
<head>
<link rel="stylesheet" type="text/css" href="about.css">
<title>morgan</title>
<style>
html {
  background: URL("https://lh3.googleusercontent.com/-lYQ3vQHE3Mo/VrVKGwg8pqI/AAAAAAAADMQ/QKjs5ALViKo/w530-d-h253-p-rw/desk%2Bbackground.png") white no-repeat center top;
  background-size: 100%;
  background-color: white;
  margin: 0;
  padding: 0;
overflow-x: none;
overflow-y:none; 
}
h2 {
Font-family: Arial;
top: 650px;
left: 500px;
position: absolute;
color: #525252;
font-size: 2vw;
letter-spacing: 1px;

}
h3 {
Font-family: Arial;
top: 900px;
left: 500px;
position: absolute;
color: #525252;
font-size: 2vw;
letter-spacing: 1px;

}
h1 {
  position: absolute;
  top: 21%;
  left: 36%;
  color: white;
  font-family: Arial;
  font-size: 4.6vw;
  letter-spacing: 1px;
}
p {
  position: absolute;
  width: 600px;
  top: 720px;
  left: 310px;
  height: 25px;
  font-family: Gill Sans, sans-serif;
color:#696969;
font-size: 17px;
 text-align: center;
line-height: 150%;
}

a {
color: white;
text-decoration:none;
}

ul li {
  font-family: Arial;
  text-align: center;
  vertical-align: middle;
  line-height: 40px;
  top: 43%;
  display: inline-block;
  margin-top: 250px;
  margin-left: 115px;
  letter-spacing: 1px;
  word-spacing: normal;
  background-color: rgba(5, 4, 2, 0.1);
  border: 2px solid white;
  color: white;
  text-align: center;
  text-decoration: none;
  font-size: 90%;
  width: 150px;
  height: 40px;
}
ul li:link,
ul li:visited {
  font-family: Arial;
  text-align: center;
  vertical-align: middle;
  line-height: 40px;
  display: inline-block;
  margin-top: 250px;
  margin-left: 115px;
  letter-spacing: 1px;
  word-spacing: normal;
  background-color: rgba(5, 4, 2, 0.1);
  border: 2px solid white;
  font-size: 90%;
  width: 150px;
  height: 40px;
  text-decoration: none;
  color: white;
}
li {
  text-decoration: none;
  color: white;
}
ul li:hover,
ul li:active {
  background-color: white;
  color: black;
  text-decoration: none;
}

ul li a:hover, ul li a:active {
  background-color: white;
  color: black;
}  

ul li a {
  display: inline-block;
  height: 100%;
  width: 100%;
  color: white;
  text-decoration: none;
}
ul {
margin-right: 10%;
}  

.wrapper {
  padding-top: 0%;
}

@media screen and (max-width: 300px) {

  .wrapper {
    padding-top: 40%;
  }

ul li{
   margin-left: 2px;
   margin-top: 5px;
   margin-bottom: 0px;
   width: 100px;
   height:35px;
   top: 480%;
  }
ul{
margin-top: 165px;
margin-left: 20px;
}
  h1{
    position:absolute;
    top: 120px;
    left: 150px;
    font-size: 19px;
 }
h2 {

    font-size: 20px;
    width: 200px; 
    left: 100px;
    top: 200px;
}

p {
    left: 30px;
    top: 390px;
}
hr {
margin-right: 85px;
margin-left: 85px;
margin-top: 375px;
}

}

<hr>
</style>
</head>
<body>
<center><h1>WHO I AM</h1></center>
<div class="wrapper">
<ul>
<li><a href="www.youtube.com" class="life" ><strong>MY LIFE</strong></a></li>
<li><a href="www.youtube.com" class="prot"><strong>PORTFOLIO</strong></a></li>
<li><a href="www.youtube.com" class="resume"><strong>RESUME</strong></a></li>
<li><a href="about.html" class="me"><strong>ABOUT ME</strong></a></li>
</ul>
</div>
<h2>Some Fun Facts</h2>
<p>
I made this website from scratch when I was 14, I have a twin brother whose <br> 
name is Pierson McNeal White, I have a older brother and sister who are also <br>
twins, I used to have 2 pet rats named Hermes and Cleo after the greek gods, <br>
and I watch the super bowl for the ads.
</p> 
<hr>
<h3>Me In A Nutshell</h3> 
</body>
</html>

Answer №1

Achieving your desired style for smaller devices can be done by utilizing media queries. Simply adjust the code as follows:

@media only screen and (max-width: 768px) {
   ul li {
      //customize the style here
   }
}

This code snippet will modify the appearance of li elements when the screen width is below 768px. Feel free to alter this value based on what you consider to be the size of a phone.

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

creating custom styling for elements within a map function

Within my React application, I am using the map JavaScript function to render a div multiple times. Each element needs to have a specific width set via CSS. The className for each div is unique. Here is how I am rendering the divs: {this.props.face_clicke ...

Error with vue html interpolation due to ReferenceError

After adding the following code snippet to my public/index.html: <script type="text/javascript"> rg4js("apiKey", "<%= VUE_APP_RAYGUN_API_KEY %>"); rg4js("enableCrashReporting", true); </script> ...

Generate a two-column table using elements from a foreach loop

I am attempting to showcase the outcomes of a foreach loop in a two-column table format. Here is the code snippet I am using: <table> @foreach (var item in items) { <tr> <td> @item.value ...

What is the best way to retrieve the innerHTML content from several Quill instances that share the same class identifier?

I have successfully implemented multiple Quill text editor instances on a single page. However, I am now facing a challenge in retrieving the innerHTML of each instance. When creating a single instance and assigning its innerHTML to a hidden input field, I ...

Choose an option from the drop-down menu in HTML

Using HTML code to select options without closing the option tag is a unique method that is functioning correctly. <div><div class="select-wrapper"> <select name="adult"> <option value="none" />Adults & ...

Guide for dynamically populating Jqgrid Dropdown depending on another dropdown's data选择如何根

On my screen, I have two dropdowns. One is a standard Razor dropdown and the other is a Jqgrid dropdown. The code for the Razor dropdown looks like this: <div class="col-md-4"> <label for="" class="control-label">Loan Currency</ ...

I am looking to share videos and large files without the use of a flash plugin

Looking for a way to upload videos without using the Flash Plugin and without relying on the browser's default browse button, especially for large files. It would be great to have a progress bar displayed during the upload process. Alternatively, is ...

The functionality of anchor links created through ajax is not operating correctly

Issue: I am encountering a problem where I have a table filled via Ajax, containing local anchors. When an anchor is clicked, it should make a section visible and automatically scroll to it. This functionality works when manually filling the table, but not ...

Obtain the text value from an HTML button in JSP code

Here is an HTML tag that I have: <button type="submit" name=<%=s %> value=<%=s %>><%=s%></button> The <%=s %> represents a String with white spaces stored on the server, such as "file one". I am facing an issue with e ...

What steps should be taken to ensure input validation in jquery SmartWizard when loading content via ajax requests?

I have successfully implemented jQuery SmartWizard to validate input type text. However, when the input text is loaded from Ajax, the validation does not work. Code for validation: // Toolbar extra buttons var btnFinish = $('<button></butto ...

Unable to get Bootstrap IMG-RESPONSIVE to function properly in Firefox and IE within the navbar

I recently encountered an issue with the Bootstrap IMG-RESPONSIVE class not functioning properly in the navigation bar on Firefox and IE. Oddly enough, it was working perfectly just a few days ago until I made some unknown changes, causing it to only work ...

JQueryMobile: Dynamic Creation of Nested Arrays

Recently, I have been delving into JQuerymobile to expand my knowledge and skillset. I created the code snippet below and wanted to confirm if JQueryMobile is able to support this type of functionality. function BooksCategory () { ID = &a ...

Ajax GET request encounters a `parsererror` in Internet Explorer due to invalid characters in XML format

I'm currently working on an app that is designed to read XML files and parse them into a data structure. So far, the XML files have been mostly error-free. However, occasionally they contain invalid characters, such as non-breaking spaces. While this ...

Adjustable image scaling with dynamic maximum height

Instead of trying to explain the problem I need to solve, let me show you an example for better clarity (apologies to mobile users, this may not work...) You can observe the effect I am aiming for on VICE news () While resizing the browser, notice how th ...

How come the button is shifting down even though it's set to display inline?

I've recently delved into the world of Bootstrap and CSS, but I'm facing a unique challenge. Despite my research efforts, I couldn't find a solution to my specific issue. I have a <div class="col-md-6"> where I've nested ...

Materialize experiencing issues with labels overlapping pre-existing content

My goal is to fill out a form using Materialize, but the written content is overlapping the input's placeholder. The JS code I'm currently using is: $("label[for='firstname']").addClass("active"); document.getElementById("firstname"). ...

Some datalist tags containing a hidden value

I came across this code here: <form action="<?php echo $adresstrust; ?>" method="post" > <input list="suggestionList" id="answerInput"> <datalist id="suggestionList"> <opt ...

Why are the Facebook like buttons not showing up with lazy loading enabled?

As I work on a project for my client, I encounter an issue with loading results onto the page. Initially, when the first 10 results are displayed, the facebook like button is perfectly rendered. However, upon clicking the bottom link to load 10 more resu ...

JQuery for sending posts rapidly with Ajax interactions

My ajax request to Express is not getting a response. The post request status stays pending for a long time in the Chrome inspector network tab before failing. Below is my express code snippet: app.configure(function(){ app.set('port', process ...

Utilizing the :not-selector in event triggers with CanJS

I find myself in a tricky situation. First, I added a click-event handler to all elements on the page that triggers a small popup. Unfortunately, I am unable to prevent the popup from opening within itself, creating an endless loop. I have attempted the ...