I am using a bootstrap carousel and for later styling purposes I added it inside a div and gave a fixed width. And also after the carousel I added 3 thumbnails which also inside that same div. Now I'm having problems regarding responsiveness of carousel and thumbnails because of the fixed width div.
Here's the code
<div class="container-fluid homecontent">
<!-- Slider -->
<div id="#slider_style">
<div id="carousel-example-generic" class="carousel slide customslider" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="images/nysm2.jpg" alt="nysm2">
<div class="carousel-caption">
...
</div>
</div>
<div class="item">
<img src="images/civil war.jpg" alt="CA civil war">
<div class="carousel-caption">
...
</div>
</div>
<div class="item">
<img src="images/deadpool1.jpg" alt="deadpool">
<div class="carousel-caption">
...
</div>
</div>
...
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" 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="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
<!-- home page movies -->
<div class="container-fluid" id="maincontent">
<div class="row">
<div class="col-md-4 col-xs-12">
<div class="thumbnail">
<img src="images/deadpool1.jpg" alt="deadpool" id="mainconimg">
<div class="caption">
<h3 id="trop">Deadpool</h3>
<p>View</p>
</div>
</div>
</div>
<div class="col-md-4 col-xs-12">
<div class="thumbnail" id="medalthumb">
<img src="images/civil war.jpg" alt="CA: Civil War" id="mainconimg2">
<div class="caption">
<h3 id="medal">CA: Civil War</h3>
<p>View</p>
</div>
</div>
</div>
<div class="col-md-4 col-xs-12">
<div class="thumbnail" id="souvnthumb">
<img src="images/nysm2.jpg" alt="nysm2" id="mainconimg3">
<div class="caption">
<h3 id="souvn">Now You See Me 2</h3>
<p>View</p>
</div>
</div>
</div>
</div>
</div>
</div>
Here's the CSS
.homecontent{
width:910px;
}
.customslider{
-webkit-box-shadow: -1px 5px 61px -6px rgba(9,212,40,1);
-moz-box-shadow: -1px 5px 61px -6px rgba(9,212,40,1);
box-shadow: -1px 5px 61px -6px rgba(9,212,40,1);
}
Need some tips to solve this..
You can't set a fixed width to an element and expect it to be responsive. Use Bootstrap's built-in grid system and easily set width according to the screen size.
Set the column width by adding a .col class that defines screen size (sm, xs, xl...) and width from 1 to 12:
<div id="carousel" class="col-sm-12 col-md-8 col-xl-2">
---content---
</div>
In this example, when the screen is small ("sm"), the element will span to 12/12 of the screen width. When it's extra-large ("xl") - it'll span to 2/12 the width of the screen, and so on.
This way, you can define custom width to any desired screen. You can even reconfigure the .col classes and give them any width you want in pixels.
You could also try and give it max and min width as per your need and add width in percentage.
In your case it could be
div{
max-width:910px;
width:100%;/* As per your preference */
}
So div would get up to a maximum of 910 width and on other screen sizes it takes up the percentage you prefer. You could also mention minimum width as well if needed. That way you can fix the width range and rest gets adjusted as per percentage.
Hope this helps.
You're not going to have responsiveness with fixed dimensions.
Use a percentage (%) or viewport width (vw) unit. For example...
.homecontent{
width: 80%;
}
.homecontent{
width: 80vw;
}
Related
I have a carousel that's the full width of the page. Now I need to make the carousel-caption the full width of the page as well with a yellow background. The background should be the full width of the page, but the actual caption text should be centered.
This is what it should look like:
This is what it looks like now:
HTML:
<!--START CAROUSEL-->
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel" data-interval="false">
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="../../images/LD/desktop_hero1.png" alt="...">
<div class="carousel-caption">
Text for caption 1 here.
</div>
</div>
<div class="item">
<img src="../../images/LD/desktop_hero2.png" alt="...">
<div class="carousel-caption">
Text for caption 2 here.
</div>
</div>
<div class="item">
<img src="../../images/LD/desktop_hero3.png" alt="...">
<div class="carousel-caption">
Text for caption 3 here.
</div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" 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="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<!--END CAROUSEL-->
CSS:
<style type="text/css">
.carousel-caption {
max-width: 100%;
width:100%;
background-color: #ffb81c;
}
</style>
carousel-caption class declares the div to have an absolute positioning with its position to be 15 % from left.
So you can try to override that. Here is the css:
.carousel-caption {
max-width: 100%;
width:100%;
background-color: #ffb81c;
left: 0;
}
you only need to add text-align: center becaus actually it uses the full width already
if something is floating u can use a clearfix to solve it, check this jsfidlle
title example
<div class="carousel-caption">
<h1>
Text for caption 1 here.
</h1>
</div>
.carousel-caption h1 {
max-width: 100%;
background-color: #ffb81c;
text-align:center;
}
pd. i added the h1 tag to have a better semantic structure.
Okay, so I'm trying to get a webpage to show a Bootstrap image carousel, which works! But I want some text to the right of it. I'm not trying to get the text to change with the image, just be to the side.
Here is the HTML for the page;
http://pastebin.com/EabGfv3H#
And here is the custom CSS I'm using;
http://pastebin.com/MEtF1hTR
And a JSFiddle;
http://jsfiddle.net/swfour/52VtD/3942/
Needed code for JSFiddle link, so here is the html;
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div id="carousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel" data-slide-to="0" class="active"></li>
<li data-target="#carousel" data-slide-to="1"></li>
<li data-target="#carousel" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="images/Beaches and Villages\Golden Beach umbrellas home.JPG" alt="...">
<div class="carousel-caption">
Golden Beach
</div>
</div>
<div class="item">
<img src="images/Beaches and Villages\Limenas ancient city.jpg" alt="...">
<div class="carousel-caption">
Limenas
</div>
</div>
<div class="item">
<img src="images/Beaches and Villages\Potos sunset.JPG" alt="...">
<div class="carousel-caption">
Potos
</div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel" 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="#carousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
<div id="carousel_text" class="col-md-6">
<div>
<p>
Thasos, an island surrounded by the crystal-clear emerald waters of the Aegean Sea is part of the Northeastern islands of
Greece, also being the closest one to the continent. It is the perfect getaway for holidays during summer, a place where
you can relax and enjoy your holidays, forget about all your worries on a quiet sandy beach, but also a place where you
can explore the Greek way of life, try the best foods and meet the most amazing people.
</p>
</div>
</div>
</div>
I've tried not using the bootstrap columns and just using float left and right, which didn't work.
From your image mockup, I assume you need the carousel on some 75% width while the other text/div on remaining 25% width within your main container. OR the text/div should be outside of carousel.
So if that's the case, try using this -
add a new class carousel-left to <div id="carousel-example-generic" class="carousel slide carousel-left" data-ride="carousel">
add/update your text-div in html as shown below:
<div class="bs-example" data-example-id="simple-carousel">
<div id="carousel-example-generic" class="carousel slide carousel-left" data-ride="carousel">...</div>
<div class="some-text">your text div</div>
</div>
add following in your css -
.carousel-left { width: 75%; float: left; }
.some-text { float: left; width: 25%; }
Hope it helps.
I add pull-left class to img, and add pull-right class to your text and place it inside <span> not <div> and remove carousel-caption from it.seems to work Pluncker
<div class="item">
<img class="pull-left" src="images/Beaches and Villages\Limenas ancient city.jpg" alt="...">
<span class="pull-right">
Limenas
</span>
</div>
I was working with carosel in bootstrap and I want background image to be blur and top image to be properly visible. For this I was using two classes in style but as a result both front and back images are coming blur. The fiddle for the same is here https://jsfiddle.net/v37wju8h/6/ . Please increase the screen size to check the problem with the result. Below is the code -
<div class="container">
<div id="carousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner"> <!-- Wrapper for slides -->
<div class="item active back_img" style="background-image:url('http://www.pluots.net/media/full/18/dining-table-contemporary-in-wood-home-fred-by-vladimir-dining-table-contemporary-in-wood-home-fred-by-vladimir.jpg');">
<img class="front_img" src="http://www.pluots.net/media/full/18/furniture-tips-to-make-marvellous-round-dining-table-furniture-tips-to-make-marvellous-round-dining-table.jpg"/>
<div class="carousel-caption">
<h3>Image1</h3>
</div>
</div>
<div class="item back_img" style="background-image:url('http://www.pluots.net/media/full/18/dining-table-contemporary-in-wood-home-fred-by-vladimir-dining-table-contemporary-in-wood-home-fred-by-vladimir.jpg');">
<img class="front_img" src="http://www.pluots.net/media/full/18/furniture-tips-to-make-marvellous-round-dining-table-furniture-tips-to-make-marvellous-round-dining-table.jpg" />
<div class="carousel-caption">
<h3>Image2 </h3>
</div>
</div>
<div class="item back_img" style="background-image:url('http://www.pluots.net/media/full/18/dining-table-contemporary-in-wood-home-fred-by-vladimir-dining-table-contemporary-in-wood-home-fred-by-vladimir.jpg');">
<img class="front_img" src="http://www.pluots.net/media/full/18/furniture-tips-to-make-marvellous-round-dining-table-furniture-tips-to-make-marvellous-round-dining-table.jpg" />
<div class="carousel-caption">
<h3>Image 3</h3>
</div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel" role="button" data-slide="prev"><span class="glyphicon glyphicon-chevron-left"></span></a>
<a class="right carousel-control" href="#carousel" role="button" data-slide="next"><span class="glyphicon glyphicon-chevron-right"></span></a>
</div>
</div>
You can use opacity
opacity: 0.5
position: relative;
I am trying to place a content DIV on bootstrap carousel. So I tried it using CSS position. But still could not figure this out.
This is my HTML -
<div id="homepage-feature" class="carousel slide">
<ol class="carousel-indicators">
<li data-target="#homepage-feature" data-slide-to="0" class="active"></li>
<li data-target="#homepage-feature" data-slide-to="1"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="http://placehold.it/1500X600">
<div class="container">
<div class="carousel-caption">
<h1>Changes to the Grid</h1>
<p>Bootstrap 3 still features a 12-column grid, but many of the CSS class names have completely changed.</p>
<p><a class="btn btn-large btn-primary" href="#">Learn more</a>
</p>
</div>
</div>
</div>
<div class="item">
<img src="http://placehold.it/1500X600">
<div class="container">
<div class="carousel-caption">
<h1>Percentage-based sizing</h1>
<p>With "mobile-first" there is now only one percentage-based grid.</p>
<p><a class="btn btn-large btn-primary" href="#">Browse gallery</a>
</p>
</div>
</div>
</div>
</div><!-- /.carousel-inner -->
<!-- Controls -->
<a class="left carousel-control" href="#homepage-feature" data-slide="prev">
‹
</a>
<a class="right carousel-control" href="#homepage-feature" data-slide="next">
›
</a>
<div class="container">
<div class="red"></div>
</div>
</div><!-- /#homepage-feature.carousel -->
This is JSFIDDLE with my current code
Can anybody tell me how to fix this proble?
Thank you.
So something like this? http://jsfiddle.net/LzdUa/131/
I just removed the container div from around the div with class="red":
<div class="red"></div>
The css your applying to the red box is only positioning it inside of the container, you will need to position the container itself. And then add extra css inside of media queries to move it below the carousel on smaller screen sizes. Or you can add an extra container and hide it on large screens and show it on small screens.
Bootstrap comes with classes already defined for hiding and showing depending on the device size so it saves you creating your own media queries.
see this here http://www.bootply.com/DzwnA7zrw6# think this is what your looking for.
The bits of the code to update are
html:
<div class="container red-position hidden-sm hidden-xs">
<div class="red"></div>
</div>
<div class="container visible-sm visible-xs">
<div class="red"></div>
</div>
css:
.carousel .red-position{
position:absolute;
top:0;
right:0;
}
I am trying to make one of these modern designs where there's a carousel of images in the top of the home page of the webpage.
I am using Bootstrap 3 and so far I have managed to make it behave the way it should, but I feel like that's only going to happen in my screen, because I worked partially with fixed proportions so the images would look perfect in my screen, so they all have the same width and height. Here's how it looks:
If these images are displayed in a thinner screen I guess there would be no problem, or would there? I still have to test this, but I am pretty sure that there would not be any problem; anyway this is not that much of a concern for me right now, I am focused in the other issue. But if they're displayed in a wider screen an ugly border will appear, just like this:
That looks really bad, I think that I should center the image and treat those borders in a way that goes well along with the image, like if both image and borders were one whole. Any ideas?
Also I would need to reposition the carousel slide buttons to be fitted in the image instead outside. I am not that sure about how to do that either.
Here the code in case you need it:
<!-- Carousel -->
<div class="this-centrar-contenido this-margen-vertical">
<div id="carousel-inicio" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-inicio" data-slide-to="0" class="active"></li>
<li data-target="#carousel-inicio" data-slide-to="1"></li>
<li data-target="#carousel-inicio" data-slide-to="2"></li>
<li data-target="#carousel-inicio" data-slide-to="3"></li>
<li data-target="#carousel-inicio" data-slide-to="4"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="img/img1.jpg">
<div class="carousel-caption">
text
</div>
</div>
<div class="item">
<img src="img/img2.jpg">
<div class="carousel-caption">
text
</div>
</div>
<div class="item">
<img src="img/img3.png">
<div class="carousel-caption">
text
</div>
</div>
<div class="item">
<img src="img/img4.png">
<div class="carousel-caption">
text
</div>
</div>
<div class="item">
<img src="img/img5.png">
<div class="carousel-caption">
text
</div>
</div>
</div> <!-- /.carousel-inner -->
</div> <!-- /#carousel-inicio -->
<!-- Controls -->
<a class="left carousel-control" href="#carousel-inicio" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left this-icono-grande"></span>
</a>
<a class="right carousel-control" href="#carousel-inicio" data-slide="next">
<span class="glyphicon glyphicon-chevron-right this-icono-grande"></span>
</a>
</div> <!-- /.col-md-12 -->
<!-- /Carousel -->
And custom css (the rest is Bootstrap 3 default for carousels)
.carousel-control
{
height: 600px;
}
For fitting the images I would use the images as background-images for each div.item, and set background-size: cover; in the css. For that each div.item needs an id or a specific class:
HTML:
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div id="img_1" class="item active">
<div class="carousel-caption">
text
</div>
</div>
<div id="img_2" class="item">
<div class="carousel-caption">
text
</div>
</div>
...
<div id="img_5" class="item">
<div class="carousel-caption">
text
</div>
</div>
</div> <!-- /.carousel-inner -->
CSS:
#img_1 {
background: url('img/img1.png') no-repeat center center;
background-size: cover;
}
#img_2 {
background: url('img/img2.png') no-repeat center center;
background-size: cover;
}
...
#img_5 {
background: url('img/img2.png') no-repeat center center;
background-size: cover;
}
Now, you won't have any problem with the different viewports. Change the size of your browser's window to test it.