水平居中图像,并在图像宽度较小时使用最大宽度叠加

时间:2016-09-01 14:38:47

标签: html css html5 css3

我的图片位于固定宽度固定的well内。

  1. (1)如何使我的图像始终水平居中(我尝试使用 margin:0 auto但它没有用)。
  2. (2)我还有.overlay 它适用于我所有的其他图像(具有 max-width:300px,但对于宽度较小的示例中的图片, 我需要叠加层也覆盖well的完整最大宽度(现在,在此示例中,叠加层限制为这些较小宽度图像的宽度)。怎么做 这两件事可能吗?
  3. .image-video-linkcar {
        position: relative;
        display: inline-block;
    }
    
    .image-video-linkcar img {
        max-width: auto;
        max-height: 230px;
        margin: 0;
        padding: 0;
        vertical-align: middle;
    }
    
    .categorycar {
        font-size: 10px;
        font-weight: 700;
        font-family: 'Montserrat',sans-serif;
        font-style: bold;
        text-align: center;
        color: #777;
        margin-left: 15px;
        outline: 1px solid #fff;
        padding: 2px 20px 2px 8px;
        background-color: #FFF;
        opacity: .9;
        position: absolute;
        opacity: .7;
        bottom: 0;
        right: 0;
        min-height: 0;
    }
    
    .brandcar {
        font-size: 10px;
        font-weight: 700;
        font-family: 'Montserrat',sans-serif;
        font-style: bold;
        text-align: center;
        color: #777;
        margin-left: 15px;
        outline: 1px solid #fff;
        padding: 2px 20px 2px 8px;
        background-color: #fff;
        opacity: .9;
        position: absolute;
        opacity: .7;
        top: 0;
        right: 0;
        min-height: 0;
    }
    
    .image-video-linkcar:hover .overlay {
        opacity: 1;
    }
    
    
    .well.carousel {
        width: 100%;
        height: auto;
        height: 420px;
        width: 400px;
        padding: 0;
        margin: 0;
        border: none;
        background-color:red
    }
    
    
    
    
    .product-detailscar .overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        opacity: 0;
        border-radius: 0;
        background: #F7F7F7;
        color: #FFF;
        padding: 10px;
        border-top: 1px solid #A10000;
        border-bottom: 1px solid #A10000;
    /*vertical-align: middle;*/
        -webkit-transition: opacity 500ms;
        -moz-transition: opacity 500ms;
        -o-transition: opacity 500ms;
        transition: opacity 500ms;
    /*padding: 25px;
        text-align: center;*/
    }
    <div class="well carousel">
                <div class="product-detailscar">
                    <div class="image-video-linkcar">
                        <img alt="#" src=
                        "http://lorempixel.com/100/200"> 
                        <div class="brandcar">
                            BRAND
                        </div>
                        <div class="categorycar">
                         CATEGORY
                        </div>
                        <div class="overlay">
                            <div class="subcategorycar">
                           SUBCAT
                        </div>
                           <div class="idcar">
                           ID
                        </div>

1 个答案:

答案 0 :(得分:1)

您需要将叠加层移出spark-submit --class org.apache.spark.examples.SparkPi --master yarn --deploy-mode cluster --executor-memory 7G --executor-cores 4 /opt/spark2/examples/jars/spark-examples_2.11-2.0.0.jar 1000000 div。

.product-detailscar
.well {
  width: 300px;
  background: orange;
  position: relative;
  text-align: center;
}
.image-video-linkcar {
  position: relative;
  display: inline-block;
}
.image-video-linkcar img {
  max-width: auto;
  max-height: 230px;
  margin: 0;
  padding: 0;
  vertical-align: middle;
}
.categorycar {
  font-size: 10px;
  font-weight: 700;
  font-family: 'Montserrat', sans-serif;
  font-style: bold;
  text-align: center;
  color: #777;
  margin-left: 15px;
  outline: 1px solid #fff;
  padding: 2px 20px 2px 8px;
  background-color: #FFF;
  opacity: .9;
  position: absolute;
  opacity: .7;
  bottom: 0;
  right: 0;
  min-height: 0;
}
.brandcar {
  font-size: 10px;
  font-weight: 700;
  font-family: 'Montserrat', sans-serif;
  font-style: bold;
  text-align: center;
  color: #777;
  margin-left: 15px;
  outline: 1px solid #fff;
  padding: 2px 20px 2px 8px;
  background-color: #fff;
  opacity: .9;
  position: absolute;
  opacity: .7;
  top: 0;
  right: 0;
  min-height: 0;
}
.well:hover .overlay {
  opacity: 1;
}
.well .overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border-radius: 0;
  background: rgba(0, 255, 0, .5);
  color: #FFF;
  padding: 10px;
  border-top: 1px solid #A10000;
  border-bottom: 1px solid #A10000;
}