简体   繁体   中英

How do I make a HTML or URL compatable for mobile phones

I have just created an HTML or URL link for multiple URLs, however, it is not compatible with mobile phones. Is there any coding that I can put into the HTML to make it compatible?

You can add media queries to your CSS to add the responsiveness. If you're not comfortable with it, then you can also try to add bootstrap library to your project and use it. They have good documentation on how to make your website responsive and fluid in nature.

Link : https://getbootstrap.com/

Use media queries,
example

@media (max-width: 767px) {
  .p{color: red;}
}

if the screen is larger than 767px the text won't be red

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>Link</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script>
      $(document).ready(function(){
        var links = [
          "http://google.com/",
          "http://stackoverflow.com/",
          "http://amazon.com/"
            ];
        $(".myLink").attr("href",links[Math.floor(Math.random() * links.length)])
      });
    </script>
  </head>
  <body>
    <a class="myLink" href="#">
      Click me to go to a random webpage
    </a>
  </body>
</html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM