0

On my web-page there should be a panel (on the left, 25% of screen's width) with square buttons on it. That's how it should be: My UI's design
But currently those buttons stretched horizontally.I need somehow stretch them vertically.
I tried to set min-width: 100%; height: auto to make height=width, but it did nothing. Also tried to equalize them using jquery - still nothing.

This is my code:

#left_panel {
  float: left;
  width: 25%;
  text-align: center;
}

.btn {
  border-radius: 25px;
  padding: 1%;
  margin: 1%;
  background-color: green;
}

.item {
  border-radius: 10px;
  float: right;
  width: 71%;
  padding: 1%;
  margin: 1%;
  background-color: grey;
}

checkbox {
  display: inline-block;
  width: auto;
}

.name {
  display: inline-block;
  background-color: white;
  width: auto;
}

.del {
  border-radius: 25px;
  display: inline-block;
  float: right;
  background-color: red;
  width: auto;
}
<div id="left_panel">
  <div class="btn" id="open">Open</div>
  <div class="btn" id="add">Add</div>
  <div class="btn" id="info">Info</div>
</div>
<div id="list">
  <!--space for list-->
</div>
Temani Afif
  • 245,468
  • 26
  • 309
  • 415
V555
  • 43
  • 6

1 Answers1

0

you can make them square with padding-bottom: 100% method.

#left_panel {
  float: left;
  width: 25%;
  text-align: center;
}

.btn {
  border-radius: 25px;
  padding: 1%;
  margin: 1%;
  background-color: green;
  position: relative;
}
.btn span {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.btn::after {
  content: '';
  display: block;
  padding-bottom: 100%;
}

.item {
  border-radius: 10px;
  float: right;
  width: 71%;
  padding: 1%;
  margin: 1%;
  background-color: grey;
}

checkbox {
  display: inline-block;
  width: auto;
}

.name {
  display: inline-block;
  background-color: white;
  width: auto;
}

.del {
  border-radius: 25px;
  display: inline-block;
  float: right;
  background-color: red;
  width: auto;
}
<div id="left_panel">
  <div class="btn" id="open"><span>Open</span></div>
  <div class="btn" id="add"><span>Add</span></div>
  <div class="btn" id="info"><span>Info</span></div>
</div>
<div id="list">
  <!--space for list-->
</div>
Chris Li
  • 2,628
  • 1
  • 8
  • 23