2016-07-07 43 views
0

我試圖把僞元素::beforeimg但它只是不會顯示。 (是Bootstrap搞砸了嗎?)之前未按預期工作

我看過其他答案,並試圖把content = "something",但它仍然不會顯示。

我也試過display: block,但它仍然保持隱形狀態。

這裏的HTML

<header class = "header container-fluid navbar navbar-fixed-top navbar-inverse"> 

<div class="container"> 
<!-- Brand and toggle get grouped for better mobile display --> 
<div class="navbar-header"> 
    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> 
    <span class="sr-only">Toggle navigation</span> 
    <span class="icon-bar"></span> 
    <span class="icon-bar"></span> 
    <span class="icon-bar"></span> 
    </button> 
    <a class="navbar-brand" href="#">Brand</a> 
</div> 

<!-- Collect the nav links, forms, and other content for toggling --> 
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">    
    <ul class="nav navbar-nav navbar-right"> 
    <li><a href="#">Anime</a></li> 
    <li><a href="#">Manga</a></li> 
    <li><a href="#">Games</a></li> 

    <li class="dropdown"> 
     <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown</a> 
     <ul class="dropdown-menu"> 
     <li> 
      <a data-toggle="modal" data-target="#myModal" >Log-In</a> 

     </li> 
     <li><a href="#">Sign-Up</a></li> 
     <li role="separator" class="divider"></li> 
     <li><a href="#">Watch Paralax</a></li> 
     </ul> 
    </li> 
    </ul> 
</div><!-- /.navbar-collapse --> 
</div><!-- /.container-fluid --> 
</header><!-- end of header--> 

<!-- MAIN IMAGE --> 
<div class = "container"> 
<img class = "img-responsive main-pic" src="http://vignette4.wikia.nocookie.net/naruto/images/d/dc/Naruto's_Sage_Mode.png/revision/latest?cb=20150124180545" alt = "naruto"> 
</div> 

這裏的CSS

img{ 
margin-top:70px; 
border-radius:10px; 
} 

img::before{ 
content:"This is not working"; 
color:black; 
font-size:200px; 
} 
+0

https://makandracards.com/makandra/8417-you-cannot-use-before-or-after-on-img-in-css –

回答

0

這是在我的其他職位answer同樣的原因。

來自specification

作者使用:before和:after僞元素指定生成內容的樣式和位置。正如它們的名稱所表明的那樣:before和之後:僞元素指定元素的文檔樹內容之前和之後的內容位置。 'content'屬性與這些僞元素一起指定插入的內容。