Bootstrap news slider
Here is an example of how to create a news slider using Bootstrap:
HTML:
<div id="news-slider" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#news-slider" data-slide-to="0" class="active"></li>
<li data-target="#news-slider" data-slide-to="1"></li>
<li data-target="#news-slider" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="image1.jpg" alt="News Image 1">
<div class="carousel-caption">
<h3>News Headline 1</h3>
<p>News summary 1</p>
</div>
</div>
<div class="carousel-item">
<img src="image2.jpg" alt="News Image 2">
<div class="carousel-caption">
<h3>News Headline 2</h3>
<p>News summary 2</p>
</div>
</div>
<div class="carousel-item">
<img src="image3.jpg" alt="News Image 3">
<div class="carousel-caption">
<h3>News Headline 3</h3>
<p>News summary 3</p>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#news-slider" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#news-slider" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
CSS:
.carousel-inner {
position: relative;
width: 100%;
overflow: hidden;
}
.carousel-item {
position: relative;
display: none;
float: left;
width: 100%;
height: 100%;
}
.carousel-item.active {
display: block;
}
.carousel-caption {
position: absolute;
top: 50%;
left: 0;
right: 0;
text-align: center;
transform: translateY(-50%);
}
.carousel-caption h3 {
font-size: 24px;
font-weight: bold;
margin-bottom: 10px;
}
.carousel-caption p {
font-size: 16px;
color: #666;
}
JavaScript:
$('#news-slider').carousel({
interval: 5000 // change the interval to 5 seconds
});
This code creates a news slider with three slides, each containing an image and a caption. The slider is controlled by the carousel indicators and the previous/next buttons. You can customize the appearance and behavior of the slider by modifying the CSS and JavaScript code.
Note: Make sure to include the Bootstrap CSS and JavaScript files in your HTML file for this code to work.