Componentes en Bootstrap

Contactar con el profesor

Aunque vamos a ver los componentes más habituales, puedes consultar en la documentación oficial todos los componentes.

Cheasheet con una colección de snippets de Bootstrap 4

Carousel de imágenes

<style>
	.overlay{
		position: absolute;
		top: 0;
		bottom: 0;
		left: 0;
		right: 0;
		color: white;
	}
</style>
</head>
<body>
  <div class="container">
    <div id="nombreCarousel" class="carousel slide" data-ride="carousel">
      <!-- Indicadores inferiores-->
      <ol class="carousel-indicators">
        <li data-target="#nombreCarousel" data-slide-to="0" class="active"></li>
        <li data-target="#nombreCarousel" data-slide-to="1"></li>
        <li data-target="#nombreCarousel" data-slide-to="2"></li>
      </ol>
      <!-- Fin Indicadores inferiores-->

      <div class="carousel-inner">
        <div class="carousel-item active">
          <img class="d-block w-100" src="https://placehold.it/600x300" alt="First slide">
          <!-- Caption de un slide -->
          <div class="carousel-caption d-none d-md-block">
            <h5>Primer caption</h5>
            <p>Texto caption</p>
          </div>
          <!-- Fin caption de un slide -->
        </div>
        <div class="carousel-item">
          <img class="d-block w-100" src="https://placehold.it/600x300" alt="Second slide">
        </div>
        <div class="carousel-item">
          <img class="d-block w-100" src="https://placehold.it/600x300" alt="Third slide">
        </div>
      </div>

      <!-- Capa overlay 
      Para que el estilo align-items-center centre verticalmente el contenido de la capa overlay
      es necesario que la capa container y la capa row tengan un height de 100%-->
      <div class="overlay">
        <div class="container" style="height: 100%">
          <div class="row align-items-center" style="height: 100%">
            <div class="col-md-6 offset-md-3 text-md-right text-center">
              <h1>Ejemplo Slider</h1>
            </div>
          </div>
        </div>
      </div>
      <!-- Fin capa overlay-->

      <!-- Flechitas de delante atrás-->
      <a class="carousel-control-prev" href="#nombreCarousel" role="button" data-slide="prev">
        <span class="carousel-control-prev-icon" aria-hidden="true"></span>
        <span class="sr-only">Previous</span>
      </a>
      <a class="carousel-control-next" href="#nombreCarousel" role="button" data-slide="next">
        <span class="carousel-control-next-icon" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
      </a>
      <!-- Fin flechitas de adelante atrás -->
    </div>

  </div>
<script>$('.carousel').carousel({
  interval: 1500
})</script>

Ejercicio carousel

Hacer un carousel con las siguientes características:

  • Dos diapositivas
  • Un caption en la segunda diapositiva
  • Un texto fijo que se vea siempre
  • Sin indicadores de progreso

Formularios

form-control

Añadimos el class form-control a los inputs, selects y textareas, para mejorar su estilo.

form-row

Una form-row es como una row, pero más cortita y con menos padding

Menú responsive

<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <a class="navbar-brand" href="#">Navbar</a>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <ul class="navbar-nav">
      <li class="nav-item active">
        <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Link</a>
      </li>
      <li class="nav-item dropdown">
        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          Dropdown
        </a>
        <div class="dropdown-menu" aria-labelledby="navbarDropdown">
          <a class="dropdown-item" href="#">Action</a>
          <a class="dropdown-item" href="#">Another action</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="#">Something else here</a>
        </div>
      </li>
    </ul>
  </div>
</nav>

Acordeón

<div id="accordion">
  <div class="card">
    <div class="card-header" id="headingOne">
      <h5 class="mb-0">
        <button class="btn btn-link" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
          Collapsible Group Item #1
        </button>
      </h5>
    </div>

    <div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
      <div class="card-body">
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
      </div>
    </div>
  </div>
  <div class="card">
    <div class="card-header" id="headingTwo">
      <h5 class="mb-0">
        <button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
          Collapsible Group Item #2
        </button>
      </h5>
    </div>
    <div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordion">
      <div class="card-body">
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
      </div>
    </div>
  </div>
  <div class="card">
    <div class="card-header" id="headingThree">
      <h5 class="mb-0">
        <button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
          Collapsible Group Item #3
        </button>
      </h5>
    </div>
    <div id="collapseThree" class="collapse" aria-labelledby="headingThree" data-parent="#accordion">
      <div class="card-body">
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
      </div>
    </div>
  </div>
</div>

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>

Tabs

<ul class="nav nav-tabs" role="tablist">
  <li class="nav-item">
    <a class="nav-link active" data-toggle="tab" href="#home" role="tab">Home</a>
  </li>
  <li class="nav-item">
    <a class="nav-link" data-toggle="tab" href="#profile" role="tab">Profile</a>
  </li>
  <li class="nav-item">
    <a class="nav-link" data-toggle="tab" href="#messages" role="tab">Messages</a>
  </li>
  <li class="nav-item">
    <a class="nav-link" data-toggle="tab" href="#settings" role="tab">Settings</a>
  </li>
</ul>

<!-- Tab panes -->
<div class="tab-content">
  <div class="tab-pane active" id="home" role="tabpanel">Home</div>
  <div class="tab-pane" id="profile" role="tabpanel">Profile</div>
  <div class="tab-pane" id="messages" role="tabpanel">Messages</div>
  <div class="tab-pane" id="settings" role="tabpanel">Settings</div>
</div>

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>

Modal

<button type="button" class="btn btn-warning" data-toggle="modal" data-target="#mipopup">
¿Quién soy?</button>


<div id="mipopup" class="modal" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">Pablo Monteserín</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <div class="row">
          <div class="col-sm-9"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laborum dignissimos expedita enim commodi repudiandae illo blanditiis similique velit, laboriosam dolore sequi a harum nobis facere vero quis, non possimus. Exercitationem!</p></div>
          <div class="col-sm-3"><img src="/curso/assets/css/bs4/landing-img/007.jpg" class="img-fluid" alt=""></div>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>
← Utils
Página sencilla con Bootstrap →

Aviso Legal | Política de privacidad