cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <ul class="wrapper">
  <li>
    <a href="">
      <div class="image">
        <img src="https://designcolor-web.com/sample/img/css-responsive-image-trimming_270x270.jpg" alt="" />
      </div>
      <p>画像を中央でトリミングして表示</p>
    </a> 
  </li>
   <li>
    <a href="">
      <div class="image">
        <img src="https://designcolor-web.com/sample/img/css-responsive-image-trimming_300x200.jpg" alt="" />
      </div>
      <p>画像を中央でトリミングして表示</p>
    </a> 
  </li>
   <li>
    <a href="">
      <div class="image">
        <img src="https://designcolor-web.com/sample/img/css-responsive-image-trimming_500x300.jpg" alt="" />
      </div>
      <p>画像を中央でトリミングして表示</p>
    </a> 
  </li>
   <li>
    <a href="">
      <div class="image">
        <img src="https://designcolor-web.com/sample/img/css-responsive-image-trimming_400x440.jpg" alt="" />
      </div>
      <p>画像を中央でトリミングして表示</p>
    </a> 
  </li>
</ul>
            
          
!
            
              body{
  padding: 5% 3%;
}
.wrapper{
  max-width: 550px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  margin: 0 auto;
}
li{
  position: relative;
  width: 48%;
  height: auto;
  margin: 0 1% 2%;
}
.image{
  position: relative;
  width: 100%;/* トリミングしたい枠の幅(固定にしたい場合はサイズを入力) */
  padding-top: 75%;/* トリミングしたい枠の高さ(固定にしたい場合はサイズを入力) */
  overflow: hidden;/* 画像が枠からはみ出た部分はトリミング(非表示)する */
  margin: 0 auto;
}
.image img{
/* 画像を上下左右に中央配置する(絶対指定) */
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  /* 画像の最大サイズは枠の1.5倍まで */
  max-width: 150%;
  max-height: 150%;
}
p{
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 5% 2%;
  font-size: 12px;
  line-height: 1.2;
  color: #fff;
  background: rgba(0,0,0, .7);
  text-align: center;
  box-sizing: border-box;
}
a{
  text-decoration: none;
}
a:hover img{
  opacity: 0.8;
}
            
          
!
999px
Loading ..................

Console