Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show an empty DIV with dynamic width?

Tags:

html

css

how can I make an empty DIV or SPAN to be shown and grow or shrink according to the content of the others?

This is what I have until now:

.text{
	float:left;
	display:inline-block;
}
.borda{
	display:inline-block;
	background-image: url('borda.png');
	background-repeat:repeat-x;
	background-position:center bottom;
	float:left;
	margin:30px 0 0 5px;
	empty-cells: show;"
}
.numbers{
	float:right;
	display:inline-block;
}
<div>
<span class="text">Text Text Text</span><span class"borda"></span><span class="numbers">Numbers</span>
</div>
like image 427
Heathz Avatar asked Nov 21 '25 21:11

Heathz


1 Answers

You can use the CSS3 flexbox specifications. Simply allow the .borda container to grow, i.e. flex-grow: 1. I have changed the background colours to show contrast. There is some error with your markup, including the missing = for the class assignment for .borda.

div {
  display: flex;
}
.text {
  background-color: #eee;
}
.borda {
  background-color: #333;
  flex-grow: 1;
}
.numbers {
  background-color: #eee;
}
<div>
  <span class="text">Text Text Text</span><span class="borda"></span><span class="numbers">Numbers</span>
</div>
like image 67
Terry Avatar answered Nov 23 '25 11:11

Terry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!