1

I'm trying to style song lyrics that are stored in an unordered list. Each lyric line is contained in a separate list item. I need these lyrics to be displayed in a two-column format and centered. The code below is the closest that I've gotten but I still have not found a viable solution for centering the text. Any help would be greatly appreciated!

h3 {
  clear: both;
  padding-top: 20px;
}

.phrases.floated {
    margin-left: auto;
    margin-right: auto;
    background-color: #ccc; /* For demo purposes */
    
    width: 600px;
}

.phrases.floated li {
    list-style-type: none;
    float: left;
}

.phrases.floated li:nth-of-type(2n+1) {
    background-color: beige; /* For demo purposes */
    clear: both;
    margin-right: 20px;
}


/* Flexbox  */
.phrases.flexbox {
    display: flex;
    flex-flow: row wrap;
    background-color: #ccc; /* For demo purposes */
    
    width: 600px;
    
}

.phrases.flexbox li {
    list-style-type: none;
    flex-basis: calc( 50% - 10px);
    text-align: left;
}

.phrases.flexbox li:nth-of-type(2n+1) {
    background-color: beige; /* For demo purposes */
    text-align: right;
    margin-right: 10px;
}
    <h3>Phrases Floated</h3>
    <ul class="phrases floated">
      <li>O beautiful for spacious skies</li>
      <li>For amber waves of grain</li>
      <li>For purple mountain majesties</li>
      <li>Above the fruited plain!</li>
      <li>America! America</li>
      <li>God shed His grace on thee</li>
      <li>And crown thy good with brotherhood</li>
      <li>From sea to shining sea!</li>
    </ul>

    <h3>Phrases Flexbox</h3>
    <ul class="phrases flexbox">
      <li>O beautiful for spacious skies</li>
      <li>For amber waves of grain</li>
      <li>For purple mountain majesties</li>
      <li>Above the fruited plain!</li>
      <li>America! America</li>
      <li>God shed His grace on thee</li>
      <li>And crown thy good with brotherhood</li>
      <li>From sea to shining sea!</li>
    </ul>
richardb
  • 15
  • 4
  • 1
    To be clear, you're saying that you want the entire row (like "O beautiful for spacious skies For amber waves of grain") to be centered together? If so, why don't you just put them in the same `
  • ` tag?
  • – StardustGogeta Jul 20 '21 at 18:49
  • like that? - https://i.ibb.co/ncZsfWR/image.png – s.kuznetsov Jul 20 '21 at 19:02
  • `text-align:center` would work for aligning the text. – tblev Jul 20 '21 at 19:25