0
<html>
<head>
<link rel="stylesheet" href="sample.css">

<link rel="stylesheet" href="./bootstrap-3.3.7-dist/css/bootstrap.min.css">
<script src="jquery.js"></script>
<script src="./bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
</head>
<body>
<div id="myCarousel" class="carousel slide">
    <!-- 轮播(Carousel)指标 -->
    <ol class="carousel-indicators">
        <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
        <li data-target="#myCarousel" data-slide-to="1"></li>
        <li data-target="#myCarousel" data-slide-to="2"></li>
    </ol>   
    <!-- 轮播(Carousel)项目 -->
    <div class="carousel-inner">
        <div class="item active">
            <img src="./img/deep.jpg" alt="First slide">
            <div class="carousel-caption">标题 1</div>
        </div>
        <div class="item">
            <img src="./img/fog.jpg" alt="Second slide">
            <div class="carousel-caption">标题 2</div>
        </div>
        <div class="item">
            <img src="./img/treefog.jpg" alt="Third slide">
            <div class="carousel-caption">标题 3</div>
        </div>
    </div>
    <!-- 轮播(Carousel)导航 -->
    <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
        <span class="sr-only"><<<<<<<<<Previous</span>
    </a>
    <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
        <span class="sr-only">Next>>>>>></span>
    </a>
</div>
</body>
</html>

sample.css

body {
}
#myCarousel{
    position:absolute;
    top:50%;
    left:50%;
}
.active {
    height:200px;
    width:500px;
    transform:translate(-200px,-200px);
}
.item {
    height:200px;
}
.carousel-caption{
    font-size:20px;
    font-family:"fangsong";
    color:red;
}

color:red想让“标题1”显示为红色,为什么无效呢?

clipboard.png

2019-04-29 提问

1 个回答

1

已采纳

sample.css和bootstrap.min.css引入的顺序反了,两者都有.carousel-caption。对于同一选择器,后引入的样式会覆盖之前的。

推广链接