Giving camuflage to home page image that isn't wide enough - html

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.

Related

Bootstrap 4 Carousel with solid color in background and Image on right and text on left

Pardon me if I am asking something silly, but I have a requirement to create a full page slider with solid color as background and some text on left side and an image on right. Something like Google's Gmail Page.
Currently the result I want is
I have used Bootstrap 4's Carousel
I have modified it slightly and made its background grey as its in Google's image. Now I want the text to be left aligned and have a responsive auto resizeable image on the right (Or even if I can have an image adjusted on the top of the text only) which is also responsive when viewed on mobile. Something like
.
I am using this fiddle and I have modified the code as
<div class="carousel-item" style="background-color: #eff0f1">
<div class="carousel-caption d-none d-md-block">
<h2 class="display-4">First Slide</h2>
<p class="lead">This is a description for the first slide.</p>
</div>
</div>
<style>
.carousel-item {
background-color: #eeeeee; /*Solid grey background*/
}
.carousel-caption {
color: black;
}
</style>
Remove d-none class from carousel-caption and try this way :
.carousel-item {
height: 100vh;
min-height: 350px;
background: no-repeat center center scroll;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.text_part{
display: none;
}
#media (max-width: 575px){
.text_part{
display: block;
}
.left_part{
display: none;
}
}
<section class="text_part">
<div class="text">
<h2 >your text</h2>
</div>
</section>
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<!-- Slide One - Set the background image for this slide in the line below -->
<div class="carousel-item active" style="background-color: gray">
<div class="carousel-caption d-md-block">
<div class="row">
<div class="col-md-6 left_part">
your text
</div>
<div class="col-md-6 col-sm-12">
img
</div>
</div>
</div>
</div>
<!-- Slide Two - Set the background image for this slide in the line below -->
<div class="carousel-item" style="background-color: pink">
<div class="carousel-caption d-md-block">
<div class="row">
<div class="col-md-6 left_part">
your text
</div>
<div class="col-md-6 col-sm-12">
img
</div>
</div>
</div>
</div>
<!-- Slide Three - Set the background image for this slide in the line below -->
<div class="carousel-item" style="background-color: green">
<div class="carousel-caption d-md-block">
<div class="row">
<div class="col-md-6 left_part">
your text
</div>
<div class="col-md-6 col-sm-12">
img
</div>
</div>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" 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="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>

how to make a div responsive after adding fixed width in bootstrap

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;
}

Bootstrap image carousel, with text to the right

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>

How can I add a cover image that sits on top of my bootstrap carousel?

I have three images that are rotating in a full page carousel. I'm trying to add a "cover" image, so to speak, that sits on top of the three rotating. This image will have a cutout that allows you to see the three rotating behind it. I'm just not sure where to place this image in the HTML or what the css would look like.
<header id="myCarousel" class="carousel">
<!-- Indicators -->
<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>
<!-- Wrapper for Slides -->
<div class="carousel-inner">
<div class="item active">
<!-- Set the first background image using inline CSS below. -->
<div class="fill" style="background-image:url('http://placehold.it/1900x1080&text=Slide One');"></div>
<div class="carousel-caption">
<h2>Caption 1</h2>
</div>
</div>
<div class="item">
<!-- Set the second background image using inline CSS below. -->
<div class="fill" style="background-image:url('http://placehold.it/1900x1080&text=Slide Two');"></div>
<div class="carousel-caption">
<h2>Caption 2</h2>
</div>
</div>
<div class="item">
<!-- Set the third background image using inline CSS below. -->
<div class="fill" style="background-image:url('http://placehold.it/1900x1080&text=Slide Three');"></div>
<div class="carousel-caption">
<h2>Caption 3</h2>
</div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="icon-prev"></span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="icon-next"></span>
</a>
</header>
<script>
$('.carousel').carousel({
interval: 500, //changes the speed
pause: false
})
</script>
html,
body {
height: 100%;
}
.carousel,
.item,
.active {
height: 100%;
}
.carousel-inner {
height: 100%;
}
.fill {
width: 100%;
height: 100%;
background-position: center;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}
Not 100% sure if I understood your question. You could add a div inside the header tag, on top and make it absolute positioned to sit on top. Adjust z-index if needed and don't forget to have header as position: relative.

Placing content DIV on bootstrap carousel

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;
}