-1

I would like to make the div class ty-product-block__wrapper align in the center (Horizontally) for all devices. The image used is for illustrative purposes only. I have been trying to figure it out for a while and I can't get it to work. Here is the jsfiddle: https://jsfiddle.net/6txxshk9/

HTML

<div class="ty-tygh">
<div class="ty-helper-container">
  <div class="row-fluid">
    <div class="span16">
      <div class="ty-product-block">
        <div lcass="ty-product-block__wrapper">
          <img src="http://blogsbucket.com/wp-content/uploads/2015/09/google-dk-flat.png">
        </div>
      </div>
    </div>
  </div>
</div>

CSS

div {display: block;
}
img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
  font-size: 0;
}
.ty-tygh {
  box-sizing: border-box;
}
.ty-helper-container {
  position: relative;
}
.row-fluid {
  width: 100%;
}
.row-fluid .span16 {
  width: 100%;
}
.row-fluid [class*="span"] {
  display: block;
  box-sizing: border-box;
  box-sizing: border-box;
  float: left;
}
.ty-product-block {
  margin: 0 0 30px 0;
  position: relative;
}
.ty-product-block__wrapper {
  background: #fff;
  padding-top: 20px;
}
Grant9196
  • 139
  • 7

1 Answers1

0

Does this work?

Horizontal Centering

.ty-product-block {
  display: block;
  text-align: center;
}

Vertical Centering

.ty-product-block {
  display: block;
  text-align: center;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
}

Fiddle: https://jsfiddle.net/6txxshk9/3/

Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252