简体   繁体   English

双百分号签到css

[英]Double percent sign in css

I'm having an issue in CSS where my div is only appearing when I have 2 percent signs. 我在CSS中有一个问题,我的div仅在我有2%的迹象时出现。

If I have: 如果我有:

<div class="col-md-8" style="display:inline-block;">
  <audio style="width:50%%" controls="controls">
    Your browser does not support the <code>audio</code> element.
    <source src="music_mix.mp3" type="audio/mp3"> 
  </audio>
</div>
<div class="col-md-4"style="display:inline-block;">Speed:
  <div class="slidecontainer" style="width:50%%"> 
    <input style="border-radius: 5px;" type="range" min="1" max="20" value="14" ng-change="updateValue()"   ng-model="trueSpeed" class="slider" ></div> {{speed}} 
  </div>
</div>

This works fine (note the 50%% on line 2). 这很好(注意第2行的50 %%)。

But if I remove the extra % sign, the audio tag dispers entirely. 但是,如果我删除额外的%符号,音频标签完全分散。

<div class="col-md-8" style="display:inline-block;">
  <audio style="width:50%%" controls="controls">
    Your browser does not support the <code>audio</code> element.
    <source src="music_mix.mp3" type="audio/mp3"> 
  </audio>
</div>
<div class="col-md-4"style="display:inline-block;">Speed:
  <div class="slidecontainer" style="width:50%"> 
    <input style="border-radius: 5px;" type="range" min="1" max="20" value="14" ng-change="updateValue()"   ng-model="trueSpeed" class="slider" ></div> {{speed}} 
  </div>
</div>

This obviously doesn't seem right , and I did not intend to type 2 in the first place. 这显然似乎不对 ,我不打算首先输入2。 What could be causing this? 可能是什么导致了这个?

Js fiddle here. Js在这里小提琴。

The width:50%% is invalid, it means <audio> will take the user agent style ie width:300px (See in the inspect) in chrome. width:50%%无效,这意味着<audio>将采用用户代理样式,即width:300px (请参阅检查中)。 Thats why its working. 这就是为什么它的工作。

The width:50% is valid, but in your case width is not working because your parent has 0 width and 0% of 0 is also 0 . width:50%有效,但在您的情况下宽度不起作用,因为您的父级有0宽度, 0% 0也是0

Try to give width in px or give width to your parent. 尝试以px给出宽度或为父级提供宽度。

Stack Snippet 堆栈代码段

 <div class="col-md-8" style="display:inline-block;"> <audio style="width:100px" controls="controls"> Your browser does not support the <code>audio</code> element. <source src="music_mix.mp3" type="audio/mp3"> </audio> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM