按字符大小制作元素的宽度

时间:2017-09-17 15:02:02

标签: html css

我想让div的宽度等于10个字符大小

假设单个字符占用def Reset(): global seven_digit seven_digit = ["","","","","","",""] global x x = 0 global eight eight = 0 global c c = 0 cinput() fcheck() def cinput(): global thing print("Enter digit ", x+1) thing = str(input("")) check() def check(): global eight global x if not thing.isdigit(): print("That character is not allowed") cinput() elif len(thing) > 1: print("Those characters are not allowed") cinput() if x < 7: seven_digit[x] = int(thing) x += 1 cinput() if x == 7: eight = int(thing) def fcheck(): #this section is temporary just for testing global c c+=1 print("This is c, ", c) print("Test") print(seven_digit) print(eight) Reset() 所以我希望宽度等于2px,即使文本只有4个字符

20px

我正在寻找的是这样的:

<div class="row"> 
     <div class="key">City</div> 
     <div class="value"><div class="XYZ">AL-NAJAF</div>
</div> 
<div class="row"> 
     <div class="key">City</div> 
     <div class="value"><div class="XYZ">NEW BAGHDAD</div>
</div>

1 个答案:

答案 0 :(得分:1)

对于等宽字体,您可以使用width: calc(10 * 6px);