Peter Kim
Peter Kim

Reputation: 25

EDIT: How do you make a container fill the width of bootstrap col class?

I am using bootstrap and hover.css to create a list-group where the list-group-items are buttons. The problem is that I can't set the width of these items to only fill the space of their parent.

EDIT: The problem was not actually that the buttons were going outside the container. It's the containers that are going outside the columns

In my html I currently have:

<div class="col-md-4">
        <div class="list-box">
            <div class="container">
                <h1>Some title</h1>
                <div class="list-group">
                    <button type="button" class="list-group-item hvr-sweep-to-left" ng-repeat="project in currentUser.projects">
                        {{Something}}
                    </button>   
                </div>
            </div>
        </div>
    </div>

In my css I currently have:

.list-box 
{
    background-color: #FFFFFF;
    border-color: #000000;
    display: block;
}

.list-group-item
{
    display: block;
    width: 100%;
}

This is the hover.css I am using

/* Button Effect - Sweep To Left */
.hvr-sweep-to-left {
  display: block;
  vertical-align: middle;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  box-shadow: 0 0 1px rgba(0, 0, 0, 0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  -webkit-transition-property: color;
  transition-property: color;
  -webkit-transition-duration: 0.3s;
  transition-duration: 0.3s;
}
.hvr-sweep-to-left:before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #4393b9;
  -webkit-transform: scaleX(0);
  transform: scaleX(0);
  -webkit-transform-origin: 100% 50%;
  transform-origin: 100% 50%;
  -webkit-transition-property: transform;
  transition-property: transform;
  -webkit-transition-duration: 0.3s;
  transition-duration: 0.3s;
  -webkit-transition-timing-function: ease-out;
  transition-timing-function: ease-out;
}
.hvr-sweep-to-left:hover, .hvr-sweep-to-left:focus, .hvr-sweep-to-left:active {
  color: white;
}
.hvr-sweep-to-left:hover:before, .hvr-sweep-to-left:focus:before, .hvr-sweep-to-left:active:before {
  -webkit-transform: scaleX(1);
  transform: scaleX(1);
}

/* Button Effect - Sweep To Right */
.hvr-sweep-to-right {
  display: block;
  vertical-align: middle;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  box-shadow: 0 0 1px rgba(0, 0, 0, 0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  -webkit-transition-property: color;
  transition-property: color;
  -webkit-transition-duration: 0.3s;
  transition-duration: 0.3s;
}
.hvr-sweep-to-right:before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #4393b9;
  -webkit-transform: scaleX(0);
  transform: scaleX(0);
  -webkit-transform-origin: 0 50%;
  transform-origin: 0 50%;
  -webkit-transition-property: transform;
  transition-property: transform;
  -webkit-transition-duration: 0.3s;
  transition-duration: 0.3s;
  -webkit-transition-timing-function: ease-out;
  transition-timing-function: ease-out;
}
.hvr-sweep-to-right:hover, .hvr-sweep-to-right:focus, .hvr-sweep-to-right:active {
  color: white;
}
.hvr-sweep-to-right:hover:before, .hvr-sweep-to-right:focus:before, .hvr-sweep-to-right:active:before {
  -webkit-transform: scaleX(1);
  transform: scaleX(1);
}

/* Back Pulse */
@-webkit-keyframes hvr-back-pulse {
  50% {
    background-color: rgba(32, 152, 209, 0.75);
  }
}

@keyframes hvr-back-pulse {
  50% {
    background-color: rgba(32, 152, 209, 0.75);
  }
}

.hvr-back-pulse {
  display: inline-block;
  vertical-align: middle;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  box-shadow: 0 0 1px rgba(0, 0, 0, 0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  -webkit-transition-duration: 0.5s;
  transition-duration: 0.5s;
  -webkit-transition-property: color, background-color;
  transition-property: color, background-color;
}
.hvr-back-pulse:hover, .hvr-back-pulse:focus, .hvr-back-pulse:active {
  -webkit-animation-name: hvr-back-pulse;
  animation-name: hvr-back-pulse;
  -webkit-animation-duration: 1s;
  animation-duration: 1s;
  -webkit-animation-delay: 0.5s;
  animation-delay: 0.5s;
  -webkit-animation-timing-function: linear;
  animation-timing-function: linear;
  -webkit-animation-iteration-count: infinite;
  animation-iteration-count: infinite;
  background-color: #2098d1;
  background-color: #2098d1;
  color: white;
}

Upvotes: 2

Views: 201

Answers (2)

touko
touko

Reputation: 2047

I'm not sure what you're looking for. However here is the solution if you want the list items to fill their parent:

body{width:100%;}
.container 
{    background-color: red;
    border-color: #000000;
    display: block;
    padding: 0;
}
h1{font-size:large;}
.list-group-item
{
    display: block;
    width: 100%;
}

Upvotes: 1

Rachel Gallen
Rachel Gallen

Reputation: 28563

I changed the bg color to red just to check the size/fitting. Jsbin link here What you're after or no?

body {
  width: 100%;
}
.container {
  background-color: red;
  border-color: #000000;
  display: block;
}
h1 {
  font-size: large;
}
.list-group-item {
  display: block;
  width: 100%;
}
<!DOCTYPE html>
<html>

<head>
  <script src="https://code.jquery.com/jquery.min.js"></script>
  <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>

<body>
  <div class="col-md-4">
    <div class="container">
      <h1>Some title</h1>
      <div class="list-group">
        <button type="button" class="list-group-item hvr-sweep-to-left" ng-repeat="project in currentUser.projects">
          {{Something}}
        </button>
        <li class="list-group-item">Coffee</li>
        <li class="list-group-item">Tea</li>
        <li class="list-group-item">Milk</li>
      </div>
    </div>

  </div>
</body>

</html>

Upvotes: 0

Related Questions