1

Is it possible to add a Logo link and social media icons when building a Jquery mobile website? I'm building a small Jquery mobile website as an assignment. The whole thing looks good but I want the logo image to link to the home page and also include a couple of social media image links using the icon links from Fontawesome.

Here is an image of the homepage. enter image description here

I want to set the planet image as a link to the home page but when I added a code to the html syntax, it obscured the image. Also in the footer I want the two media icons to be position on the right side of the copyright tagline in an in-line block on the same line but I couldn't make that happen with my current code.

Here is a snippet of the two codes for the header and the footer sections.

<div data-role="page" id="home" data-theme="d">
    <div data-role="header"> 
      <a href="#index">
        <img src="images/planetgradient-sm.png" width="53px" height="35px" class="ui-btn-left"></a>
       <h1>Amateur Astronomy</h1>
       <a href="#nav-panel" data-icon="gear" class="ui-btn-right">More Options</a>
    </div>
 </div>

 and this is the code for the footer:
<div data-role="footer">
   <div data-role="icons">
     <ul>
       <li><h2>&copy; Amateur Astronomy 2021</h2></li>
       <li><i class="fab fa-facebook"></i></li>
       <li><i class="fab fa-twitter-square"></i></li>
    </ul>
  </div>
</div>

What changes should I make to the code to get the right affect for the footer area? I welcome your suggestions. Thank you in advance.

Jake T
  • 11
  • 2

1 Answers1

1

You need to keep the header and footer structure as described inside the docs. This structure contains:

  • one or more buttons aligned to the left (ui-btn ui-btn-left)
  • the title (ui-title)
  • one or more buttons aligned to the right (ui-btn ui-btn-right)

After that, You can apply Your own icons and images using the CSS background-image.

Be aware: the framework has its own CSS, so You may need to override some styles by using the !important rule (see here: What does !important mean in CSS?)

DEMO:

.ui-icon-logo {
  width: 38px !important;
  height: 38px !important;
  background-size: contain;
  border-style: none !important;
  background-color: transparent !important;
  background-image: url("https://upload.wikimedia.org/wikipedia/commons/8/81/Stackoverflow_icon.png");
}
.ui-icon-logo:after {
  border-radius: 0 !important;
  background-color: transparent !important;
}
.ui-social-icon {
  margin-left: 0.15em !important;
  border-style: none !important;
  -webkit-border-radius: .3125em !important;
  border-radius: .3125em !important;
}
.ui-social-icon:after {
  width: 28px !important;
  height: 28px !important;
  margin-left: -14px !important;
  margin-top: -14px !important;
  -webkit-border-radius: 0 !important;
  border-radius: 0 !important;
  background-color: transparent !important;
}
.ui-icon-fb {
  background-color: #1c468e !important;
}
.ui-icon-fb:after {
  background-image: url("data:image/svg+xml,%3Csvg height='28' width='28' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 203.5 203.4'%3E%3Cpath fill='%23fff' d='M170.403 98.499h-26.1v-15.8c0-5.7 4.6-10.4 10.4-10.4h15.7v-33.2h-18.4c-22.6 0-40.9 18.3-40.9 40.9v18.5h-16.2v28.1h16.2v76.8h33.2v-76.8h26.1v-28.1z'/%3E%3C/svg%3E");
}
.ui-icon-twitter {
  background-color: #55ADEE !important;
}
.ui-icon-twitter:after {
  background-image: url("data:image/svg+xml,%3Csvg height='28' width='28' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 203.5 203.4'%3E%3Cpath fill='%23fff' d='M160.704 52.296s-10.1 6.2-16.1 6.2c0 0-4.5-7.6-17.6-8.1s-20.3 8.2-23.7 13.2-3.4 16.3-2.3 18.4c0 0-32.2.4-53.3-26.7 0 0-11.3 20 8.1 33.8 0 0-6.3.2-11.8-2.7 0 0-.1 19.8 20.4 25.3 0 0-6.2 2.2-11.2.6 0 0 3.6 15.7 23.3 17.7 0 0-11.6 12.6-37.2 10.6 0 0 36 27.7 77.9 1.2 37.3-23.6 34.5-66 34.5-66s9.8-6.3 12.6-13c0 0-7.3 2.7-14.3 3.7.1-.1 11-8.9 10.7-14.2z'/%3E%3C/svg%3E");
}
.ui-icon-youtube {
  background-color: #FF0000 !important;
}
.ui-icon-youtube:after {
  background-image: url("data:image/svg+xml,%3Csvg height='28' width='28' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 203.5 203.4'%3E%3Cpath fill='%23fff' d='M101.81 53.094c-13.598 0-37.098 1.118-44.498 1.718-7.8.6-17.118 4.194-19.218 14.094-2 9.7-2.406 19.906-2.406 32.904s.406 23.08 2.406 32.88c2.1 9.9 11.518 13.52 19.218 14.12 7.4.6 30.9 1.69 44.498 1.69s37.1-1.09 44.5-1.69c7.8-.6 17.09-4.22 19.19-14.12 2-9.7 2.41-19.88 2.41-32.88s-.41-23.204-2.41-32.904c-2.1-9.9-11.49-13.494-19.19-14.094-7.4-.6-30.9-1.718-44.5-1.718zM83.094 81l37.216 20.81-37.216 20.78V81z'/%3E%3C/svg%3E");
}
.ui-icon-linkedin {
  background-color: #0A66C2 !important;
}
.ui-icon-linkedin:after {
  background-image: url("data:image/svg+xml,%3Csvg height='28' width='28' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 203.5 203.4'%3E%3Cpath fill='%23fff' d='M168.919 116.206v49.672h-28.78v-46.339c0-11.65-4.172-19.575-14.589-19.575-7.951 0-12.7 5.353-14.773 10.522-.761 1.863-.971 4.434-.971 7.032v48.36H81.021V79.261h28.785v12.28l-.184.289h.184v-.289c3.831-5.878 10.653-14.301 25.951-14.301 18.971 0 33.167 12.385 33.167 38.966zm-118.05-78.69c-9.84 0-16.295 6.455-16.295 14.957s6.271 14.983 15.927 14.983h.184c10.05 0 16.295-6.665 16.295-14.983s-6.245-14.957-16.111-14.957zM36.28 165.886h28.811V79.269H36.28z'/%3E%3C/svg%3E");
}
.ui-icon-instagram {
  background: #f09433 !important;
  background: -webkit-linear-gradient(45deg, #f09433 0%,#e6683c 25%,#dc2743 50%,#cc2366 75%,#bc1888 100%) !important;
  background: linear-gradient(45deg, #f09433 0%,#e6683c 25%,#dc2743 50%,#cc2366 75%,#bc1888 100%) !important;
}
.ui-icon-instagram:after {
  background-image: url("data:image/svg+xml,%3Csvg height='26' width='26' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 203.5 203.4'%3E%3Cpath d='M154.1 59.5a8 8 0 1 1-16 0 8 8 0 1 1 16 0zm-52.4 1.1c-22.7 0-41.1 18.5-41.1 41.1 0 22.7 18.5 41.1 41.1 41.1 22.7 0 41.1-18.5 41.1-41.1.1-22.6-18.4-41.1-41.1-41.1zm0 68.1c-14.9 0-27-12.1-27-27s12.1-27 27-27 27 12.1 27 27-12.1 27-27 27zm39-107.5h-78c-22.9 0-41.5 18.6-41.5 41.5v78c0 22.9 18.6 41.5 41.5 41.5h78c22.9 0 41.5-18.6 41.5-41.5v-78c0-22.8-18.6-41.5-41.5-41.5zm27.4 119.5c0 15.1-12.3 27.3-27.3 27.3h-78c-15.1 0-27.3-12.3-27.3-27.3v-78c0-15.1 12.3-27.3 27.3-27.3h78c15.1 0 27.3 12.3 27.3 27.3v78z' fill='%23fff'/%3E%3C/svg%3E");
}
<!DOCTYPE html>
<html>
  <head>
    <title>Amateur Astronomy</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
    <link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.css" />
    <script src="https://code.jquery.com/jquery-1.11.2.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.js"></script>
  </head>
  <body>
    <div data-role="page">
      <div data-role="header">
        <a class="ui-btn ui-btn-left ui-btn-icon-notext ui-icon-logo" href="https://stackoverflow.com" target="_blank">Stackoverflow</a>
        <div class="ui-title">Amateur Astronomy</div>
        <a href="#nav-panel" class="ui-btn ui-btn-icon-left ui-icon-gear ui-btn-right">Options</a>      
      </div>
      <div role="main" class="ui-content"></div>
      <div data-role="footer">
        <div class="ui-title ui-btn ui-disabled ui-controlgroup-label" style="background-color: transparent;">&copy; Amateur Astronomy 2021</div>
        <div class="ui-btn-right">
          <a href="https://facebook.com" target="_blank" class="ui-btn ui-social-icon ui-icon-fb ui-btn-icon-notext">Facebook</a>
          <a href="https://twitter.com" target="_blank" class="ui-btn ui-social-icon ui-icon-twitter ui-btn-icon-notext">Twitter</a>
          <a href="https://youtube.com" target="_blank" class="ui-btn ui-social-icon ui-icon-youtube ui-btn-icon-notext">YouTube</a>
          <a href="https://linkedin.com" target="_blank" class="ui-btn ui-social-icon ui-icon-linkedin ui-btn-icon-notext">LinkedIn</a>
          <a href="https://instagram.com" target="_blank" class="ui-btn ui-social-icon ui-icon-instagram ui-btn-icon-notext">Instagram</a>
        </div>
      </div>
    </div>
  </body>
</html>

(I am not a font-awesome expert - so, inside my snippet I am using some simple SVG icons)

deblocker
  • 7,629
  • 2
  • 24
  • 59