Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
201 views
in Technique[技术] by (71.8m points)

html - Images getting smaller when I apply display:flex

I'm trying to reproduce this idea using Flexbox:

this idea

The deck div is red and the dealer-cards is green.

.table .dealer-area {
  grid-area: d;
  padding-left: 32px;
  width: 100%;
  
}

.table .dealer-area .shell-deck-and-cards{
  display: flex;
  margin-top: 25px;
  
}

.table .dealer-area .shell-deck-and-cards img{
  max-width:100%;
  max-height:100%;
}

.table .dealer-area .shell-deck-and-cards .deck, .table .dealer-area .shell-deck-and-cards .dealer-cards{
  width: 170px;
}

.table .dealer-area .shell-deck-and-cards .deck{
  margin-right: calc(100px - (0.3 * 100px));
}

.table .dealer-area .shell-deck-and-cards .dealer-cards {
  display: flex;
}
<div class="table">
<div class="dealer-area">
                <div class="dealer-name">
                    <h1>Dealer</h1>
                </div>
                <div class="shell-deck-and-cards">
                    <div class="deck">
                        <img src="assets/cards/back.svg">
                    </div>
                    <div class="dealer-cards">
                        <img src="assets/cards/2.svg">
                        <img src="assets/cards/2.svg">
                        <img src="assets/cards/2.svg">
                    </div>
                    

                </div>      
            </div>
 </div>
question from:https://stackoverflow.com/questions/65649768/images-getting-smaller-when-i-apply-displayflex

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

use width instead of max-width or min-height instead of max-height

.table .dealer-area {
  grid-area: d;
  padding-left: 32px;
  width: 100%;
  
}

.table .dealer-area .shell-deck-and-cards{
  display: flex;
  margin-top: 25px;
  
}

.table .dealer-area .shell-deck-and-cards img{
  width:100%;
  max-height:100%;
}

.table .dealer-area .shell-deck-and-cards .deck, .table .dealer-area .shell-deck-and-cards .dealer-cards{
  width: 170px;
}

.table .dealer-area .shell-deck-and-cards .deck{
  margin-right: calc(100px - (0.3 * 100px));
}

.table .dealer-area .shell-deck-and-cards .dealer-cards {
  display: flex;
}
<div class="table">
<div class="dealer-area">
                <div class="dealer-name">
                    <h1>Dealer</h1>
                </div>
                <div class="shell-deck-and-cards">
                    <div class="deck">
                        <img src="https://sites.google.com/a/netcmmi.com/share/_/rsrc/1473734124982/img/png/s/star-e01.png">
                    </div>
                    <div class="dealer-cards">
                        <img src="https://sites.google.com/a/netcmmi.com/share/_/rsrc/1473734124982/img/png/s/star-e01.png">
                        <img src="https://sites.google.com/a/netcmmi.com/share/_/rsrc/1473734124982/img/png/s/star-e01.png">
                        <img src="https://sites.google.com/a/netcmmi.com/share/_/rsrc/1473734124982/img/png/s/star-e01.png">
                    </div>
                    

                </div>      
            </div>
 </div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...