0

I'm trying to get my images centered with my anchor text and I want them to go across horizontally. I also want the images and anchor text to be centered with the form.

Here's the full page: enter image description here

Here's a picture of the problem: enter image description here

I want the text that says, "Facebook, Google, and Apple ID" to be centered with the images and I also want the images and anchor text to be centered with the text above that says, "or sign up using...". I tried using "display: flex" for the anchor text and images but they stacked on top of each other, so I had to use "display: inline-flex" so they would go across horizontally.

/* the main page */

.main {
  display: table-cell;
  width: 89.3%;
  vertical-align: top;
  background-color: rgba(17, 13, 13, 0.904);
}

form {
  border: 3px solid rgb(26, 25, 25);
  background-color: rgb(26, 25, 25);
  border-radius: 5px;
  height: 85%;
  width: 60%;
  margin-top: 15px;
  margin-left: 70px;
}

h1 {
  text-align: center;
  color: white;
  font-size: 28pt;
  font-family: 'Montserrat', sans-serif;
}

#user {
  margin-left: 40px;
  margin-right: 7.4em;
  font-family: 'Inter', sans-serif;
  color: rgb(172, 164, 164);
  font-size: 10pt;
}

#username {
  padding-top: 10px;
  padding-bottom: 10px;
  margin-right: 13em;
  border-radius: 5px;
  margin-bottom: 1.5em;
  width: 303px;
  background-color: rgb(54, 53, 53);
  border: 3px solid rgb(54, 53, 53);
  font-family: 'Inter', sans-serif;
  color: rgb(172, 164, 164);
  font-size: 10pt;
}

#mail {
  margin-left: 40px;
  margin-right: 9.7em;
  font-family: 'Inter', sans-serif;
  color: rgb(172, 164, 164);
  font-size: 10pt;
}

#email {
  padding-top: 10px;
  padding-bottom: 10px;
  margin-right: 13em;
  border-radius: 5px;
  width: 304px;
  margin-bottom: 1.5em;
  background-color: rgb(54, 53, 53);
  border: 3px solid rgb(54, 53, 53);
  font-family: 'Inter', sans-serif;
  color: rgb(172, 164, 164);
  font-size: 10pt;
}

#pass {
  margin-left: 40px;
  margin-right: 7.5em;
  font-family: 'Inter', sans-serif;
  color: rgb(172, 164, 164);
  font-size: 10pt;
}

#password {
  padding-top: 10px;
  padding-bottom: 10px;
  margin-right: 13.1em;
  border-radius: 5px;
  margin-bottom: 1.5em;
  width: 304px;
  background-color: rgb(54, 53, 53);
  border: 3px solid rgb(54, 53, 53);
  font-family: 'Inter', sans-serif;
  color: rgb(172, 164, 164);
  font-size: 10pt;
}

#skill {
  margin-left: 40px;
  margin-right: 7.5em;
  font-family: 'Inter', sans-serif;
  color: rgb(172, 164, 164);
  font-size: 10pt;
}

#skill_level {
  padding-top: 10px;
  padding-bottom: 10px;
  margin-right: 13.1em;
  border-radius: 5px;
  width: 313px;
  margin-bottom: 1.5em;
  background-color: rgb(54, 53, 53);
  border: 3px solid rgb(54, 53, 53);
  font-family: 'Inter', sans-serif;
  color: rgb(172, 164, 164);
  font-size: 10pt;
}

#account {
  margin-left: 15.6em;
  width: 315px;
  padding-top: 12px;
  padding-bottom: 12px;
  text-align: center;
  background-color: rgb(76, 163, 76);
  border: solid 3px rgb(76, 163, 76);
  border-radius: 8px;
  color: white;
  margin-bottom: 1em;
}

#account:hover {
  background-color: rgb(86, 228, 86);
  border: 3px solid rgb(86, 228, 86);
  color: white;
}

#alternatives {
  text-align: center;
  font-family: 'Inter', sans-serif;
  color: rgb(172, 164, 164);
  font-size: 10pt;
}

#facebook {
  font-family: 'Inter', sans-serif;
  color: rgb(172, 164, 164);
  font-size: 10pt;
  display: inline-flex;
  text-align: center;
}

form a {
  font-family: 'Inter', sans-serif;
  color: rgb(172, 164, 164);
  font-size: 10pt;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  top: 5px;
}

form img {
  display: inline-flex;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <title>Chess Facts</title>
  <meta charset="utf-8" />
  <link rel="stylesheet" href="../styles/signin.css">
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@700&display=swap" rel="stylesheet">
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@700&display=swap" rel="stylesheet">
</head>

<body>
  <div id="outer-container">
    <div class="sidebar">
      <a href="#" id="chess_com"><img src='../images/best chess.com logo.png' id="chess-logo" alt="chess_logo" height='33px' width='110px'></a>

      <div class="subnav">
        <a href="play.html" class="subnavbtn"><img src="../images/play logo.webp" alt="play" id="play" height='25px' width='25px'><span>Play</span></a>
        <div class="subnav-content">
          <a href="#"><img src="../images/play logo.webp" id="chess" alt="play" height="21px" width="21px">Play</a>
          <a href="#"><img src="../images/live chess icon (1).png" id="live" height="21px" width="21px"><span id="lively">Live Chess</span></a>
          <a href="#"><img src="../images/sun icon (1).png" id="daily" height="21px" width="21px">Daily Chess</a>
          <a href="#"><img src="../images/computer icon (1).png" id="comp" height="23px" width="21px">Computer</a>
          <a href="#"><img src="../images/tournament_icon (1).png" id="tourney" height="22px" width="16px">Tournaments</a>
          <a href="#"><img src="../images/4_player_chess_icon (1).png" id="four" height="27px" width="27px">4 Player Chess</a>
          <a href="#"><img src="../images/chess_variants_icon (1).png" id="var" height="28px" width="36px">Variants</a>
          <a href="#"><img src="../images/leaderboards_icon (1).png" id="leader" height="25px" width="25px">Leaderboard</a>
          <a href="#"><img src="../images/library_icon (1).png" id="lib" height="25px" width="25px">Library</a>
        </div>
      </div>

      <div class="subnav">
        <a href="puzzles.html" class="subnavbtn"><img src="../images/puzzle_piece_logo (1).png" alt="puzzles" id="puzzles" height='26px' width='26px'>Puzzles</a>
        <div class="subnav-content">
          <a href="#"><img src="../images/puzzle_piece_logo (1).png" id="mypuz" height="22px" width="22px">Puzzles</a>
          <a href="#"><img src="../images/puzzle logo.png" height="22px" id="puz_rush" width="22px">Puzzle Rush</a>
          <a href="#"><img src="../images/puzzle battle logo.png" id="puz_battle" height="22px" width="22px">Puzzle Battle</a>
          <a href="#"><img src="../images/daily puzzle logo (1).png" id="daily_puz" height="22px" width="22px">Daily Puzzle</a>
          <a href="#"><img src="../images/solo chess logo (1).png" id="solo_chess" height="22px" width="22px">Solo Chess</a>
          <a href="#"><img src="../images/drills logo (1).png" id="drills" height="22px" width="22px">Practice (Drills)</a>
          <a href="#"><img src="../images/endgames logo (1).png" id="endgames" height="22px" width="22px">Endgames</a>
        </div>
      </div>

      <div class="subnav">
        <a href="learn.html" class="subnavbtn"><img src="../images/learn_logo (1).png" alt="learn" id="learn" height='23px' width='25px'>Learn</a>
        <div class="subnav-content">
          <a href="#"><img src="../images/learn_logo (1).png" id="lessons" height="22px" width="22px">Lessons</a>
          <a href="#"><img src="../images/analysis icon (1).png" id="analysis" height="22px" width="22px">Analysis</a>
          <a href="#"><img src="../images/articles (1).png" id="articles" height="28px" width="28px">Articles</a>
          <a href="#"><img src="../images/videos icon (1).png" id="videos" height="28px" width="28px">Videos</a>
          <a href="#"><img src="../images/vision icon (1).png" id="vision" height="25px" width="25px">Vision</a>
          <a href="#"><img src="../images/chess openings icon (1).png" id="openings" height="27px" width="27px">Openings</a>
          <a href="#"><img src="../images/explorer icon (1).png" id="explorer" height="22px" width="22px">Explorer</a>
        </div>
      </div>

      <div class="subnav">
        <a href="today.html" class="subnavbtn"><img src="../images/news logo (1).png" alt="today" id="today" height='30px' width='35px'>Today</a>
        <div class="subnav-content">
          <a href="#"><img src="../images/chess today icon (1).png" id="chess_today" height="25px" width="25px">Chess Today</a>
          <a href="#"><img src="../images/news logo (1).png" id="new_news" height="30px" width="35px">News</a>
          <a href="#"><img src="../images/chessTV icon (1).png" id="tv" height="27px" width="27px">ChessTV</a>
          <a href="#"><img src="../images/streamers icon (1).png" id="streamers" height="30px" width="35px">Streamers</a>
          <a href="#"><img src="../images/events icon (1).png" id="events" height="28px" width="28px">Events</a>
        </div>
      </div>

      <div class="subnav">
        <a href="connect.html" class="subnavbtn"><img src="../images/message logo (1).png" alt="connect" id="connect" height='27px' width='40px'>Connect</a>
        <div class="subnav-content">
          <a href="#"><img src="../images/message logo (1).png" id="forums" height='25px' width='35px'>Forums</a>
          <a href="#"><img src="../images/chess clubs icon (1).png" id="clubs" height="22px" width="28px">Clubs</a>
          <a href="#"><img src="../images/blogs icon (1).png" id="blogs" height="25px" width="30px">Blogs</a>
          <a href="#"><img src="../images/world icon (1).png" id="members" height="30px" width="30px">Members</a>
          <a href="#"><img src="../images/coaches icon (1).png" id="coaches" height="30px" width="30px">Coaches</a>
        </div>
      </div>


      <div class="subnav">
        <a href="more.html" class="subnavbtn"><img src="../images/more logo (1).png" alt="more" id="more" height='28px' width='35px'>More</a>
        <div class="subnav-content">
          <a href="#"><img src="../images/master games icon (1).png" id="master" height="22px" width="22px">Master Games</a>
          <a href="#"><img src="../images/mobile apps icon (1).png" id="mobile" height="22px" width="22px">Mobile Apps</a>
          <a href="#"><img src="../images/shop icon (1).png" id="shop" height="22px" width="22px">Shop</a>
          <a href="#"><img src="../images/merch icon (1).png" id="merch" height="22px" width="22px">Merch</a>
          <a href="#"><img src="../images/resources icon (1).png" id="resources" height="22px" width="22px">Resources</a>
          <a href="#"><img src="../images/vote chess icon (1).png" id="vote" height="22px" width="22px">Vote Chess</a>
          <a href="#"><img src="../images/top players icon (1).png" id="top" height="22px" width="22px">Top Players</a>
          <a href="#"><img src="../images/chess rankings icon (1).png" id="ranking" height="25px" width="18px">Chess Rankings</a>
          <a href="#"><img src="../images/chess terms icon (1).png" id="terms" height="22px" width="22px">Chess Terms</a>
          <a href="#"><img src="../images/play logo.webp" id="rules" height="22px" width="22px">Rules</a>
          <a href="#"><img src="../images/chess kids icon (1).png" id="kid" height="25px" width="18px">ChessKid</a>
          <a href="#"><img src="../images/computer championship icon (1).png" id="comp_champ" height="22px" width="22px">Computer Championship</a>
        </div>
      </div>

      <a href="sign-in.html" id="sign_up" target="_blank">Sign Up</a>
      <a href="log-in.html" id="log_in" target="_blank">Log In</a>

      <div id="bottom_sidebar">
        <a href="" id="search"><img src="../images/search icon (1).png" alt='search'>Search</a>
        <div id="mininav">
          <a href="#" id="help"><img src="../images/question icon (1).png" alt='search'>Help</a>
          <div id="second_subnav-content">
            <a href="#">Ask a Question</a>
            <a href="#">Report Abuse</a>
            <a href="#">Make a Suggestion</a>
            <a href="#">Billing Issues</a>
            <a href="#">Report a Bug</a>
          </div>
        </div>
      </div>
    </div>

    <div class="main">
      <form action="/chess.php">
        <h1>Join Now -- It's Free & Easy!</h1>

        <label id="user" for="user">Username</label>
        <input type="username" id="username" name="username" size="40">

        <label id="mail" for="email">Email</label>
        <input type="email" id="email" name="email" size="40">

        <label id="pass" for="password">Password</label>
        <input type="password" id="password" name="password" size="40">

        <label id="skill" for="skill">Skill Level</label>
        <select name="skill_level" id="skill_level">
          <option value="New to Chess">New to Chess</option>
          <option value="Beginner">Beginner</option>
          <option value="Intermediate">Intermediate</option>
          <option value="Advanced">Advanced</option>
          <option value="Expert">Expert</option>
        </select>

        <button id="account">Create Your FREE Account</button>

        <p id="alternatives">Or Sign Up Using...</p>
        <div id="socials">
          <a href="#" id="facebook"><img src="../images/facebook logo (1).png">Facebook</a>
          <a href="#"><img src="../images/google logo (1).png">Google</a>
          <a href="#"><img src="../images/apple logo (1).png">Apple ID</a>
        </div>
      </form>



    </div>
  </div>
</body>
john fernado
  • 127
  • 8
  • are you sure you mean horizontally not vertically? Easiest way: `flexbox + align-items: center;` not `inline-flex` – tacoshy Aug 02 '21 at 06:44
  • I don't want the images and anchor text stacked on top of each other. I want them to go across horizontally. @tacoshy – john fernado Aug 02 '21 at 06:47
  • I'm aware of what you want. Flexbox will not display the items below each other by default but align the text vertically with `align-items: center;` to be centered within the icon height. – tacoshy Aug 02 '21 at 06:49
  • What would the code look like? @tacoshy – john fernado Aug 02 '21 at 06:51
  • `.subnav-content a { display: inline-flex; align-items: center; }` <- should already do what you want. The `align-items: center` part is the important one. – tacoshy Aug 02 '21 at 06:53
  • I made you a snippet. Please update it (for example with images from placeholder.com) to provide a [mcve] – mplungjan Aug 02 '21 at 07:08
  • Where's the snippet? @mplungjan – john fernado Aug 02 '21 at 07:23
  • Reload the page and look at your question – mplungjan Aug 02 '21 at 07:27
  • I wanted you to look at my css code that says, "form a". I already used "display: inline-flex" and "text-align: center" on that selector and my anchor text and images are still messed up. I wanted that to be fixed. I looked at the snippet that you made and it doesn't show the google, facebook, or apple logos at all which should be at the very bottom of the page. @mrplungjan – john fernado Aug 02 '21 at 07:34

5 Answers5

0
.subnav-content a { 
 display: flex; 
 align-items: center;
  }

this will work

Shivam
  • 370
  • 2
  • 6
  • The ".subnav-content a" is apart of the code for my sidebar. The code that manipulates the images and text that I'm trying to fix is inside of the css code that says "form a". I tried using "display: flex" and "align-items: center" but that doesn't work. @shivam – john fernado Aug 02 '21 at 07:09
0

Add text-align: center;" to your socials div:

#socials {
  text-align: center;
}

It will look like this

It will look like this

GucciBananaKing99
  • 1,473
  • 1
  • 11
  • 31
0

I wasn't referencing my div tag that said, "#flex container" and "#flex container a" which was containing my anchor tags and image tags.

Code:

#flex-container {
    display: flex;
    justify-content: center;
}

#flex-container a {
    font-family: 'Inter', sans-serif;
    color: rgb(172, 164, 164);
    font-size: 10pt;
    text-decoration: none;
    display: flex;
    align-items: center;
}

image of solution: enter image description here

john fernado
  • 127
  • 8
0

Your problems seems to be not addressing the right tag, or class. this happens a lot, and it is a common mistake.

You either need to add display: flex; to the #socials, and write jusfity-content: flex-center

you can also use text-align: center; on #socials.

Please let me know if you need further guidance

  • I decided to encapsulate my anchor text and images inside of a div called #flex-container and justify-content: center and also used display: flex to get the content centered and you can see the rest from the answer I posted. @Eternal – john fernado Aug 02 '21 at 08:24
0

This will work 100%

The only thing you should add to the anchor tag style is align-items: center.

And to get the whole p and div centered, you should wrap those into a div and give it a class and then add this code to this div:

div {
   display: flex;
   justify-content: center;
   align-items: center;
}

All of the code is here:

HTML:

<div class="container">
    <p id="alternatives">Or Sign Up Using...</p>
    <div id="socials">
        <a href="#"><img src="asset/facebook-brands.svg"></img>Facebook</a>
        <a href="#"><img src="asset/google-brands.svg"></img>Google</a>
        <a href="#"><img src="asset/apple-brands.svg"></img>Apple ID</a>
    </div>
</div>

CSS:

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
}

#socials {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
}

#socials a {
    display: flex;
    justify-content: center;
    align-items: center;
    text-decoration: none;
    gap: 10px;
    color: black;
}

#socials img {
    width: 50px;
    height: 50px;
}

A Little Note:

  1. I used my own icons.
  2. The "container" is the className of the wrapper of p and div elements.