Override and reset CSS style: auto or none don't work

后端 未结 7 1252
灰色年华
灰色年华 2021-01-30 04:50

I would like to override following CSS styling defined for all tables:

table {
        font-size: 12px;
        width: 100%;
        min-width: 400px;
               


        
7条回答
  •  终归单人心
    2021-01-30 05:22

    I ended up using Javascript to perfect everything.

    My JS fiddle: https://jsfiddle.net/QEpJH/612/

    HTML:

    Full Size Image - For Reference

    CSS:

    .container {
        background-color:#000;
        width:100px;
        height:200px;
    
        display:flex;
        justify-content:center;
        align-items:center;
        overflow:hidden;
    
    }
    

    JS:

    $(".container").each(function(){
        var divH = $(this).height()
        var divW = $(this).width()
        var imgH = $(this).children("img").height();
        var imgW = $(this).children("img").width();
    
        if ( (imgW/imgH) < (divW/divH)) { 
            $(this).addClass("1");
            var newW = $(this).width();
            var newH = (newW/imgW) * imgH;
            $(this).children("img").width(newW); 
            $(this).children("img").height(newH); 
        } else {
            $(this).addClass("2");
            var newH = $(this).height();
            var newW = (newH/imgH) * imgW;
            $(this).children("img").width(newW); 
            $(this).children("img").height(newH); 
        }
    })
    

提交回复
热议问题