sdsd
sdsd

Reputation: 517

My chip card text goes out of the bounds on small sizes

.chip {
  display: inline-block;
  padding: 0 25px;
  height: 50px;
  font-size: 18px;
  line-height: 50px;
  border-radius: 25px;
  background-color: #f1f1f1;
}

.chip img {
  float: left;
  margin: 0 10px 0 -25px;
  height: 50px;
  width: 50px;
  border-radius: 50%;
}

.closebtn {
  padding-left: 10px;
  color: #888;
  font-weight: bold;
  float: right;
  font-size: 20px;
  cursor: pointer;
}

.closebtn:hover {
  color: #000;
}
<div class="chip">
  <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/99/Unofficial_JavaScript_logo_2.svg/480px-Unofficial_JavaScript_logo_2.svg.png" alt="Person" width="96" height="96">
  John Doe Extra long Text
  <span class="closebtn" onclick="this.parentElement.style.display='none'">&times;</span>
</div>

I have chip cards.

css

.chip {
  display: inline-block;
  padding: 0 25px;
  height: 50px;
  font-size: 18px;
  line-height: 50px;
  border-radius: 25px;
  background-color: #f1f1f1;
}

.chip img {
  float: left;
  margin: 0 10px 0 -25px;
  height: 50px;
  width: 50px;
  border-radius: 50%;
}

.closebtn {
  padding-left: 10px;
  color: #888;
  font-weight: bold;
  float: right;
  font-size: 20px;
  cursor: pointer;
}

.closebtn:hover {
  color: #000;
}

html

<div class="chip">
  <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/99/Unofficial_JavaScript_logo_2.svg/480px-Unofficial_JavaScript_logo_2.svg.png" alt="Person" width="96" height="96">
  John Doe Extra long Text
  <span class="closebtn" onclick="this.parentElement.style.display='none'">&times;</span>
</div>

everything looks good on big screens - but on small screens - because the text is long - it goes under the width of the chip together with the close button out of the card bounds - how can i make this responsive alwways - regarding on the text included inside

i tried

adding min-height instead height on chip class

min-height: 50px;

but it goes on the left under the image - i don't want that i want the image to be automatically heighted down together with the text

Upvotes: 0

Views: 151

Answers (1)

Lalji Tadhani
Lalji Tadhani

Reputation: 14159

Use flex

.chip {
  display: inline-flex;
  padding: 0 25px;
  font-size: 18px;
  align-items:center;
  border-radius: 25px;
  background-color: #f1f1f1;
}

.chip img {
  margin: 0 10px 0 -25px;
  height: 50px;
  width: 50px;
  border-radius: 50%;
}

.closebtn {
  padding-left: 10px;
  color: #888;
  font-weight: bold;
  
  font-size: 20px;
  cursor: pointer;
}

.closebtn:hover {
  color: #000;
}

https://jsfiddle.net/lalji1051/hqexb3w0/7/

Upvotes: 1

Related Questions