Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is causing my text to be center aligned in desktop?

I'm using Bootstrap 4's accordion on this page, and the text of the last item of the accordion is being centered. I'm not using text-center nor do I have a CSS property of text-align: center so I have no idea what is causing this. All the accordion's text is centered in mobile only, not desktop.

enter image description here

My code:

.accordion-faq .card {
  border-radius: 0;
  border: 1px solid #F1F5F7;
  border-right: none;
  border-left: none;
  text-align: left;
}

.accordion-faq .card-header {
  background-color: white;
  border-bottom: none;
}

.accordion-faq .card-header button {
  color: #0074e1;
  padding-left: 0;
  font-size: 0.9em;
}

.accordion-faq .card-header h5 button::after {
  content: '\f107';
  font-family: 'Font Awesome 5 Free';
  font-weight: 900;
  color: #0074e1;
  position: absolute;
  right: 35px;
  top: 19px;
}

.accordion-faq .card-header h5 button[aria-expanded="true"]:after {
  content: '\f077';
  font-family: 'Font Awesome 5 Free';
  font-weight: 900;
  color: #0074e1;
  position: absolute;
  right: 35px;
  top: 19px;
  font-size: 0.8em;
}

.accordion-faq .card-body {
  color: #494D53;
  font-style: normal;
  font-weight: normal;
  font-size: 1em;
  line-height: 25px;
}

.accordion-faq .card-body a {
  color: #0074e1;
}

.faq-no-answer {
  font-style: normal;
  font-weight: normal;
  font-size: 0.9em;
  letter-spacing: 0.02em;
  color: #494D53;
  margin-top: 50px;
}


/* Media Query */

@media (max-width: 992px) {
  .accordion-faq,
  .accordion-faq .card-header,
  .accordion-faq .card-body {
    text-align: center !important;
  }
  .accordion-faq .card-header h5 button::after {
    display: none;
  }
  .accordion-faq .card-header h5 button[aria-expanded="true"]:after {
    display: none;
  }
}
<!-- Bootstrap CDN -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<!-- Fontawsome CDN -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">


<!-- Faq Vendedores -->
<div class="col-lg-9 col-md-12 col-sm-12 col-12  mx-auto" id="faqVendedores">
  <hr class="separator">
  <p class="middle-title-thin text-center">Vendedores</p>
  <!-- Accordion -->
  <div id="accordion" class="accordion-faq">
    <div class="card">
      <div class="card-header" id="headingQuestionOne">
        <h5 class="mb-0">
          <button class="btn btn-link" data-toggle="collapse" data-target="#collapseQuestionOne" aria-expanded="false" aria-controls="collapseQuestionOne">
              ¿Por qué debería agregar company como una opción de pago?
            </button>
        </h5>
      </div>

      <div id="collapseQuestionOne" class="collapse" aria-labelledby="headingQuestionOne" data-parent="#accordion">
        <div class="card-body">
          company es mundialmente reconocida por sus características y facilidad de uso. Nuestra cobertura mundial con múltiples idiomas y tipos de moneda se traducen en un notorio aumento de tu potencial clientela. Nuestro equipo de soporte está listo para ayudarte
          a aprovechar, de la mejor manera posible, nuestros servicios.
        </div>
      </div>
    </div>

    <div class="card">
      <div class="card-header" id="headingQuestionThirtyone">
        <h5 class="mb-0">
          <button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseQuestionThirtyone" aria-expanded="false" aria-controls="collapseQuestionThirtyone">
              ¿Puedo insertar botones de pago en múltiples páginas web?
            </button>
        </h5>
      </div>
      <div id="collapseQuestionThirtyone" class="collapse" aria-labelledby="headingQuestionThirtyone" data-parent="#accordion">
        <div class="card-body">
          Sí, puedes hacer esto siempre y cuando las páginas se encuentren en el mismo sitio web. Debido a razones de cumplimiento y/o conformidad, si tienes múltiples sitios web necesitarás solicitar la creación de una nueva cuenta en company para cada website.
        </div>
      </div>
    </div>

    <div class="card">
      <div class="card-header" id="headingQuestionThirtytwo">
        <h5 class="mb-0">
          <button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseQuestionThirtytwo" aria-expanded="false" aria-controls="collapseQuestionThirtytwo">
              ¿Puedo reemplazar la imagen del botón de pago de company por una propia?
            </button>
        </h5>
      </div>
      <div id="collapseQuestionThirtytwo" class="collapse" aria-labelledby="headingQuestionThirtytwo" data-parent="#accordion">
        <div class="card-body">
          Por supuesto, simplemente reemplaza la URL de la imagen.
        </div>
      </div>
    </div>

    <div class="card">
      <div class="card-header" id="headingQuestionThirtythree">
        <h5 class="mb-0">
          <button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseQuestionThirtythree" aria-expanded="false" aria-controls="collapseQuestionThirtythree">¿Por qué recibo un mensaje de error cuando trato de acceder a mi archivo IPN desde en navegador?</button>
        </h5>
      </div>
      <div id="collapseQuestionThirtythree" class="collapse" aria-labelledby="headingQuestionThirtythree" data-parent="#accordion">
        <div class="card-body">
          Algunos archivos IPN «listos para usar» pueden incluir medidas de seguridad para asegurarse de que la notificación de pago realmente proviene de company. En estos casos, al intentar acceder al archivo desde tu navegador se mostrará un mensaje de error.
          Si necesitas probar notificaciones, recomendamos utilizar un botón de pago y cambiar tu cuenta a modo Test.
        </div>
      </div>
    </div>

  </div>
  <!-- /Accordion -->
  <p class="text-center faq-no-answer">¿No encontraste tu respuesta? Envíanos un correo a <a href="mailto:[email protected]">[email protected]</a></p>
</div>
<!-- /Faq Vendedores -->




<script src="js/popper.min.js"></script>
<script src="js/popper.min.js.map"></script>
<script src="js/jquery.min.js"></script>
like image 741
Paula Avatar asked Sep 09 '20 12:09

Paula


People also ask

How do I change my text alignment settings?

Press one of the shortcut keys to adjust the alignment of any highlighted text. For left alignment, highlight the text and press Ctrl + Shift + L . For center alignment, highlight the text and press Ctrl + Shift + E . For right alignment, highlight the text and press Ctrl + Shift + R .

What control changes the text alignment to right?

Change text alignment To align the text left, press Ctrl+L. To align the text right, press Ctrl+R.

What is centered text alignment?

centered—text is aligned to neither the left nor right margin; there is an even gap on each side of each line.

Should you center align or left align your pages?

You can use center alignment in small doses like main page headings without detracting from the user’s experience. Paragraph text can get away with being center-aligned if it has 3 or fewer lines of text, any more then left-aligned should be used as the text becomes too notably annoying to read.

What is the difference between center text and left aligned text?

There’s an example of centered text versus left aligned text and which is easier to read. When Should I Center Text? When considering the text alignment for your web page content (or for email newsletters, flyers, and anything else with paragraphs of information) centered text should be reserved for certain instances:

Why is center text alignment bad for user experience?

The reason why center text alignment is horrible for user experience is that with each new line the user reads, there is a brief moment where the user has to find where the next line begins – decreasing the users reading speed. Intentionally handicapping your user’s ease of reading? Hell yes!

What are the default text alignment settings?

The following example shows center aligned, and left and right aligned text (left alignment is default if text direction is left-to-right, and right alignment is default if text direction is right-to-left):


2 Answers

The partial reason is because the button has text-align center and if removed from your style sheet, the button will naturally have text-align center. The reason you don't see it occuring to your other elements is because the other buttons are not the full-width of their h5 containers.

To understand what I am saying add:

.btn {
    width: 100%
}

To your button class, you will notice all buttons actually text-align center, not just the last one. Adding width 100% gives all your button elements "room" to align center.

The initial reason, you don't see it with your last option until your text wraps is because your button is the same width as your h5 "container", but once it is forced to wrap there is room for it to align center.

So to fix your problem add:

.btn {
    width: 100%;  /*Optional*/
    text-align: left;
}

To those elements you do not want to align center.

like image 198
leroyjenkinss24 Avatar answered Oct 18 '22 01:10

leroyjenkinss24


It's the .btn class of bootstrap. You need to override it's text-align property.

.accordion-faq .card {
  border-radius: 0;
  border: 1px solid #F1F5F7;
  border-right: none;
  border-left: none;
  text-align: left;
}

.accordion-faq .card-header {
  background-color: white;
  border-bottom: none;
}

.accordion-faq .card-header button {
  color: #0074e1;
  padding-left: 0;
  font-size: 0.9em;
}

.accordion-faq .card-header h5 button::after {
  content: '\f107';
  font-family: 'Font Awesome 5 Free';
  font-weight: 900;
  color: #0074e1;
  position: absolute;
  right: 35px;
  top: 19px;
}

.accordion-faq .card-header h5 button[aria-expanded="true"]:after {
  content: '\f077';
  font-family: 'Font Awesome 5 Free';
  font-weight: 900;
  color: #0074e1;
  position: absolute;
  right: 35px;
  top: 19px;
  font-size: 0.8em;
}

.accordion-faq .card-body {
  color: #494D53;
  font-style: normal;
  font-weight: normal;
  font-size: 1em;
  line-height: 25px;
}

.accordion-faq .card-body a {
  color: #0074e1;
}

.faq-no-answer {
  font-style: normal;
  font-weight: normal;
  font-size: 0.9em;
  letter-spacing: 0.02em;
  color: #494D53;
  margin-top: 50px;
}


/* Media Query */

@media (max-width: 992px) {
  .accordion-faq,
  .accordion-faq .card-header,
  .accordion-faq .card-body {
    text-align: center !important;
  }
  .accordion-faq .card-header h5 button::after {
    display: none;
  }
  .accordion-faq .card-header h5 button[aria-expanded="true"]:after {
    display: none;
  }
}

.accordion-faq .card-header .btn {
  text-align: left;
}
<!-- Bootstrap CDN -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<!-- Fontawsome CDN -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">


<!-- Faq Vendedores -->
<div class="col-lg-9 col-md-12 col-sm-12 col-12  mx-auto" id="faqVendedores">
  <hr class="separator">
  <p class="middle-title-thin text-center">Vendedores</p>
  <!-- Accordion -->
  <div id="accordion" class="accordion-faq">
    <div class="card">
      <div class="card-header" id="headingQuestionOne">
        <h5 class="mb-0">
          <button class="btn btn-link" data-toggle="collapse" data-target="#collapseQuestionOne" aria-expanded="false" aria-controls="collapseQuestionOne">
              ¿Por qué debería agregar company como una opción de pago?
            </button>
        </h5>
      </div>

      <div id="collapseQuestionOne" class="collapse" aria-labelledby="headingQuestionOne" data-parent="#accordion">
        <div class="card-body">
          company es mundialmente reconocida por sus características y facilidad de uso. Nuestra cobertura mundial con múltiples idiomas y tipos de moneda se traducen en un notorio aumento de tu potencial clientela. Nuestro equipo de soporte está listo para ayudarte
          a aprovechar, de la mejor manera posible, nuestros servicios.
        </div>
      </div>
    </div>

    <div class="card">
      <div class="card-header" id="headingQuestionThirtyone">
        <h5 class="mb-0">
          <button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseQuestionThirtyone" aria-expanded="false" aria-controls="collapseQuestionThirtyone">
              ¿Puedo insertar botones de pago en múltiples páginas web?
            </button>
        </h5>
      </div>
      <div id="collapseQuestionThirtyone" class="collapse" aria-labelledby="headingQuestionThirtyone" data-parent="#accordion">
        <div class="card-body">
          Sí, puedes hacer esto siempre y cuando las páginas se encuentren en el mismo sitio web. Debido a razones de cumplimiento y/o conformidad, si tienes múltiples sitios web necesitarás solicitar la creación de una nueva cuenta en company para cada website.
        </div>
      </div>
    </div>

    <div class="card">
      <div class="card-header" id="headingQuestionThirtytwo">
        <h5 class="mb-0">
          <button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseQuestionThirtytwo" aria-expanded="false" aria-controls="collapseQuestionThirtytwo">
              ¿Puedo reemplazar la imagen del botón de pago de company por una propia?
            </button>
        </h5>
      </div>
      <div id="collapseQuestionThirtytwo" class="collapse" aria-labelledby="headingQuestionThirtytwo" data-parent="#accordion">
        <div class="card-body">
          Por supuesto, simplemente reemplaza la URL de la imagen.
        </div>
      </div>
    </div>

    <div class="card">
      <div class="card-header" id="headingQuestionThirtythree">
        <h5 class="mb-0">
          <button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseQuestionThirtythree" aria-expanded="false" aria-controls="collapseQuestionThirtythree">¿Por qué recibo un mensaje de error cuando trato de acceder a mi archivo IPN desde en navegador?</button>
        </h5>
      </div>
      <div id="collapseQuestionThirtythree" class="collapse" aria-labelledby="headingQuestionThirtythree" data-parent="#accordion">
        <div class="card-body">
          Algunos archivos IPN «listos para usar» pueden incluir medidas de seguridad para asegurarse de que la notificación de pago realmente proviene de company. En estos casos, al intentar acceder al archivo desde tu navegador se mostrará un mensaje de error.
          Si necesitas probar notificaciones, recomendamos utilizar un botón de pago y cambiar tu cuenta a modo Test.
        </div>
      </div>
    </div>

  </div>
  <!-- /Accordion -->
  <p class="text-center faq-no-answer">¿No encontraste tu respuesta? Envíanos un correo a <a href="mailto:[email protected]">[email protected]</a></p>
</div>
<!-- /Faq Vendedores -->




<script src="js/popper.min.js"></script>
<script src="js/popper.min.js.map"></script>
<script src="js/jquery.min.js"></script>
like image 2
Debsmita Paul Avatar answered Oct 18 '22 00:10

Debsmita Paul