Home > front end >  Display the text inside the div carousel indicators
Display the text inside the div carousel indicators

Time:10-20

I have 3 tabs designed from the bootstrap carousel. The tabs need to be named as Step1, 2 and 3.

I have placed names Step 1, 2 and 3 respectively in the carousel-indicator divs but its not appearing. Any help is greatly appreciated.

<style>
.carousel-indicators {
  display: flex!important;
  position: inherit!important;
  justify-content: space-between!important;
}

.carousel-indicators [data-bs-target] {flex: 1 0 auto!important;} 
.carousel-indicators {  margin-left: auto!important;  margin-right: auto!important;}


.carousel-indicators .active {
 border-bottom: blue 5px solid!important;
}

.page{
    height:50px!important;
    background:#efefef!important;
    margin:0px!important;
}
</style>

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA /3y gxIOqMEjwtxJY7qPCqsdltbNJuaOe923 mo//f6V8Qbsw3" crossorigin="anonymous"></script>

<div  id="accordionExample">
  <div >
    <h2  id="headingOne">
      <button  type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
        <input  value="Accordion Item #1" />
      </button>
    </h2>
    <div id="collapseOne"  aria-labelledby="headingOne" data-bs-parent="#accordionExample">
      <div >

        <div id="carouselExampleDark"  data-bs-ride="false" data-bs-interval="false">

          <div >



            <div type="button" data-bs-target="#carouselExampleDark" data-bs-slide-to="0"  aria-current="true" aria-label="Slide 1">Step1</div>
            <div type="button" data-bs-target="#carouselExampleDark" data-bs-slide-to="1"  aria-label="Slide 2">Step2</div>
            <div type="button" data-bs-target="#carouselExampleDark" data-bs-slide-to="2"  aria-label="Slide 3">Step3</div>




          </div>

          <div id="carouselExampleControls"  data-bs-ride="false" data-bs-wrap="false">
            <div >
              <div >
                <p >Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.



                </p>
                <div >
                </div>
              </div>
              <div >
                <p >Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.



                </p>
                <div >
                </div>
              </div>
              <div >
                <p >It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
                </p>
                <div >
                </div>
              </div>
            </div>

            <button  type="button" data-bs-target="#carouselExampleDark" data-bs-slide="prev">
            <span >Previous</span>
          </button>
            <button  type="button" data-bs-target="#carouselExampleDark" data-bs-slide="next">

            <span >Next</span>
          </button>
          </div>
        </div>
      </div>
    </div>
  </div>

CodePudding user response:

The text is not visible because of the text-indent property being set to -999px. The fix would be to add it to the indicator with the target attribute as follows .carousel-indicators [data-bs-target] { text-indent: 0!important; }.

You can see this working below along with a few additional styles I've added to center the text. Disclaimer: not all of the styles may be required so feel free to tinker and keep what you need.

.carousel-indicators [data-bs-target] {
  flex: 1 0 auto!important;
  text-indent: 0!important;
  display: flex!important;
  justify-content: center!important;
  align-items: center!important;
}

I have kept !important in my examples to match the code style, but personally, I would remove the usages of !important everywhere and instead try to increase specificity another way. See How do I avoid using !important? and https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity

.carousel-indicators {
  display: flex!important;
  position: inherit!important;
  justify-content: space-between!important;
}

.carousel-indicators [data-bs-target] {
  flex: 1 0 auto!important;
  text-indent: 0!important;
  display: flex!important;
  justify-content: center!important;
  align-items: center!important;
}

.carousel-indicators {
  margin-left: auto!important;
  margin-right: auto!important;
}

.carousel-indicators .active {
  border-bottom: blue 5px solid!important;
}

.page {
  height: 50px!important;
  background: #efefef!important;
  margin: 0px!important;
}
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous" />

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA /3y gxIOqMEjwtxJY7qPCqsdltbNJuaOe923 mo//f6V8Qbsw3" crossorigin="anonymous"></script>

<div  id="accordionExample">
  <div >
    <h2  id="headingOne">
      <button  type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
        <input  value="Accordion Item #1" />
      </button>
    </h2>
    <div id="collapseOne"  aria-labelledby="headingOne" data-bs-parent="#accordionExample">
      <div >
        <div id="carouselExampleDark"  data-bs-ride="false" data-bs-interval="false">
          <div >
            <div type="button" data-bs-target="#carouselExampleDark" data-bs-slide-to="0"  aria-current="true" aria-label="Slide 1">
              Step1
            </div>
            <div type="button" data-bs-target="#carouselExampleDark" data-bs-slide-to="1"  aria-label="Slide 2">
              Step2
            </div>
            <div type="button" data-bs-target="#carouselExampleDark" data-bs-slide-to="2"  aria-label="Slide 3">
              Step3
            </div>
          </div>

          <div id="carouselExampleControls"  data-bs-ride="false" data-bs-wrap="false">
            <div >
              <div >
                <p >
                  Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up
                  one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of
                  "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit
                  amet..", comes from a line in section 1.10.32.
                </p>
                <div ></div>
              </div>
              <div >
                <p >
                  Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
                  survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently
                  with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
                </p>
                <div ></div>
              </div>
              <div >
                <p >
                  It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here,
                  content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy.
                  Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
                </p>
                <div ></div>
              </div>
            </div>

            <button  type="button" data-bs-target="#carouselExampleDark" data-bs-slide="prev">
              <span >Previous</span>
            </button>
            <button  type="button" data-bs-target="#carouselExampleDark" data-bs-slide="next">
              <span >Next</span>
            </button>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

  • Related