如何隐藏div html?

时间:2018-05-05 07:24:48

标签: javascript html css

<div class="navigation-menu w-32 d-flex flex-row">
   <div class="visible"><a href="#">Раздел1</a></div>
   <div class="visible"><a href="#">Раздел1</a></div>
   <div class="visible"><a href="#">Раздел1</a></div>
   <div class="visible"><a href="#">Раздел1</a></div>
   <div class="visible"><a href="#">Раздел1</a></div>
   <div id="more-hd more-vis"><i class="fas fa-chevron-circle-down"></i></div>  
 </div>

我试图隐藏最后一个Div.I使用bootstrap.So,d-none也没有帮助,在css #more-hd display:none中也有JS document.getElementById("more-hd").style.display = "none"。它总是可见的..我也尝试过ul&gt;李先生......没有任何反应

5 个答案:

答案 0 :(得分:5)

使用div向最后一个!important添加一个类到最后一个div并在该类中使用该css。使用id将覆盖已应用于此div的css。你也有多个.lastDiv{ display: none !important; },这是一个不好的做法,所以在那里使用一个id。

<div class="navigation-menu w-32 d-flex flex-row">
          <div class="visible"><a href="#">Раздел1</a></div>
          <div class="visible"><a href="#">Раздел1</a></div>
          <div class="visible"><a href="#">Раздел1</a></div>
          <div class="visible"><a href="#">Раздел1</a></div>
          <div class="visible"><a href="#">Раздел1</a></div>
          <div id="more-hd more-vis" class='lastDiv'>SomeContent<i class="fas fa-chevron-circle-down"></i></div>  
</div>
id

如果您想使用id,请在此代码中使用单个#more-hd{ display: none !important; }值:

<div class="navigation-menu w-32 d-flex flex-row">
          <div class="visible"><a href="#">Раздел1</a></div>
          <div class="visible"><a href="#">Раздел1</a></div>
          <div class="visible"><a href="#">Раздел1</a></div>
          <div class="visible"><a href="#">Раздел1</a></div>
          <div class="visible"><a href="#">Раздел1</a></div>
          <div id="more-hd" class='lastDiv'>SomeContent<i class="fas fa-chevron-circle-down"></i></div>  
</div>
last-child

您还可以在css中选择id选择器,以确保classdiv内容为navigation-menu内部.navigation-menu div:last-child{ display: none !important; }内的<div class="navigation-menu w-32 d-flex flex-row"> <div class="visible"><a href="#">Раздел1</a></div> <div class="visible"><a href="#">Раздел1</a></div> <div class="visible"><a href="#">Раздел1</a></div> <div class="visible"><a href="#">Раздел1</a></div> <div class="visible"><a href="#">Раздел1</a></div> <div id="more-hd more-vis" class='lastDiv'>SomeContent<i class="fas fa-chevron-circle-down"></i></div> </div>,永远是隐藏的:

 getImage(id: string): Observable<Blob> {
    return this.httpClient.get('http://myip/image/'+id, {responseType: "blob"});
}
class Date:
    def __init__(self, *args):
        if len(args) == 3:
            self._day, self._month, self._year = args
        elif len(args) == 1:
            self._day = args[0]._day
            self._month = args[0]._month
            self._year = args[0]._year
        else:
            raise TypeError("wrong number of arguments to Date constructor")

    # methods
    # checkDate - Check if the date is valid
    def checkDate (self, day, month, year):
        if year > 0 and month > 0 and month < 13 and day > 0 and day < 32:       
            if month == 1 or 3 or 5 or 7 or 8 or 10 or 12: return True
            if month == 4 or 6 or 9 or 11:
                if day == 31: return False
                return True
            if month == 2:
                if (month % 4 == 0 and (month % 100 != 0 or (month % 100 == 0 and month % 400 == 0))):
                       if day > 28: return False   
                       elif day > 27: return False
        return False        

    # calculateDate - Computes the day number since the beginning of the Christian counting of years.
    def calculateDate (self, day, month, year):
        if month < 3:
            year -= 1
            month = month + 12
        return 365 * year + year/4 - year/100 + year/400 + ((month+1) * 306)/10 + (day - 62);

    # getDay - Return the day
    def getDay(self): return self._day

    # getMonth - Return the month

    def getMonth(self): return self._month

    # getYear - Return the year
    def getYear(self): return self._year

    # setDay - Sets the day (only if date remains valid)
    def setDay(self, dayToSet):
        if checkDate(dayToSet,_month,_year): _day = dayToSet

    # setMonth - Sets the month (only if date remains valid)
    def setMonth (self, monthToSet):
        if checkDate(_day,monthToSet,_year): _month = monthToSet 

    # setYear - sets the year (only if date remains valid)
    def setYear(self, yearToSet):
        if checkDate(_day,_month,yearToSet): _year = yearToSet

def main():
    birthDate = Date(1,1,2000)
    print(birthDate.getDay())
    print(birthDate.getMonth())
    print(birthDate.getYear())
    birthDate.setDay(8)
    birthDate.setMonth(8)
    birthDate.setYear(1987)
    print(birthDate.getDay())
    print(birthDate.getMonth())
    print(birthDate.getYear())


if __name__ == "__main__": main()

答案 1 :(得分:1)

您还使用:last-child

  

注意:ID始终是唯一的。所以没有两个id的意思

&#13;
&#13;
.navigation-menu div:last-child {
display: none !important;
}
&#13;
<div class="navigation-menu w-32 d-flex flex-row">
   <div class="visible"><a href="#">Раздел1</a></div>
   <div class="visible"><a href="#">Раздел1</a></div>
   <div class="visible"><a href="#">Раздел1</a></div>
   <div class="visible"><a href="#">Раздел1</a></div>
   <div class="visible"><a href="#">Раздел1</a></div>
   <div id="more-hd"><i class="fas fa-chevron-circle-down"></i>test</div>  
 </div>
&#13;
&#13;
&#13;

答案 2 :(得分:0)

id="more-hd" 中没有空格。如果你想把CSS放在id="more-hd more-vis" 上,它应该是

{{1}}

不是

{{1}}

如果您需要多种方式来引用该元素,请使用其他类的类。它只能有一个ID。

答案 3 :(得分:0)

&#13;
&#13;
...
s=bwconncomp(BWClass);
fragmentsize=sum(cellfun(@numel,s.PixelIdxList));
....
&#13;
.navigation-menu .fa-chevron-circle-down{
		display: none;
	}
&#13;
&#13;
&#13;

答案 4 :(得分:0)

请申请此Css。

.navigation-menu div:last-child {
    display: none;
}