Swiper (?) doesn't behave perfectly when displaying images under IE11. The images are rendered perfectly on Chrome and Firefox.
And you can see this live here
Here's the code (for what it's worth, it's laravel that generates it)
<div class="row">
<div class="col-xs-12">
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-car"></i> {{ trans('navs.general.pictures') }}
</div>
<div class="panel-body">
<div class="swiper-container">
<div class="swiper-pagination"></div>
<div class="swiper-button-next"></div>
<div class="swiper-button-prev"></div>
<div class="swiper-wrapper">
#foreach($car->getMedia('vehicules') as $i)
<div class="swiper-slide" style="background-image:url({{ $i->getUrl() }})">
<img data-src="{{ $i->getUrl() }}" src="{{ $i->getUrl() }}" alt="Photo">
</div>
#endforeach
</div>
</div>
</div>
</div><!-- panel -->
</div><!-- col-md-10 -->
</div><!--row-->
#section('after-scripts')
<script src='/js/swiper/swiper.jquery.js'></script>
<script>
$(document).ready(function () {
//initialize swiper when document ready
var mySwiper = new Swiper ('.swiper-container', {
// Optional parameters
pagination: '.swiper-pagination',
paginationClickable: true,
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
})
});
</script>
#stop
#section('before-styles')
<link rel="stylesheet" href="/css/swiper/swiper.css">
<style>
html, body {
position: relative;
height: 100%;
}
.swiper-container {
width: 100%;
height: 100%;
}
.swiper-slide {
text-align: center;
font-size: 18px;
background: #fff;
width: auto;
/* Center slide text vertically */
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
}
</style>
#stop
EDIT:
This fixed it:
.swiper-container img {
width: 100%;
}
The image itself has max-width: 100%;. The actual width is being defined by .swiper-container .swiper-container-horizontal but there's a few layers of divs with width: 100% between that.
This issue is probably easier to fix than it is to understand. I'm on Linux, but I'll give some guesses.
It may be that because the image doesn't have width, IE uses the max-width.
Try defining the width on the image.
Try removing the max-width, and/or applying it to a parent.
Related
So what I've got is a landing page that should show a.) a header b.) a large picture that fills the screen on desktop and c.) a navbar. The navbar should scroll along the page once it's reached the top of the page.
Now, the only way I would know to ensure that all three of those elements fit perfectly into the viewport on desktop is with max-height: 100vh in a parent element. However, I'd like to make the navbar scroll along once it's at the top of the screen. This isn't possible when the navbar is in its own container, because it'll stop scrolling along once it's hit the bottom of its container.
Does anyone know of a fix? Below is a sample of the structure I'm trying to use right now:
<div class="container-top">
<header>
<!--- ...header content... -->
</header>
<div>
<img src="1080p_image.png">
</div>
<nav class="sticky-top">
<!-- ...navbar content... -->
</nav>
</div>
<div class="other-content">
<!-- ...other content... -->
</div>
.container-top{
max-height: 100vh;
display: flex;
flex-direction: column;
justify-content: space-between;
}
img{
width: 100vw;
}
header{
background-color: darkgray;
height: 5rem;
z-index: 1;
}
nav{
background-color: darkgray;
height: 5rem;
z-index: 1;
}
.sticky-top{
position: sticky;
top: 0;
}
.other-content{
height: 100rem;
}
Have you tried moving your nav into its own div below div.container-top?
<div class="container-top">
<header>
<!-- ...header content -->
</header>
<div>
<img/>
</div>
</div>
<div>
<nav class="sticky-top">
<!-- ..navbar content... -->
</nav>
</div>
<div class="other-content">
<!-- ...other content... -->
</div>
And if you want these elements to take up 100vh:
.container-top {
max-height: 75vh;
display: flex;
flex-direction: column;
justify-content: space-between;
}
nav {
max-height: 25vh;
}
Lemme know how that works for ya.
div class container is used to wrap all other items of the web page, I want to align this container centrally but can't seem to figure out why it isn't working.
edit: I would like the container itself center on the viewpoint and then I want to individually align the items within their own containers.
edit 2: I have figured it out, thanks for everyone's responses. I changed the HTML selector to the body, then changed the display to flex and finally justify-self to align-items.
* {
margin: 0;
padding: 0;
}
html {
display: block;
flex-direction: column;
width: 100%;
justify-self: center;
}
h1 {
text-align: center;
}
.sub {
position: absolute;
}
.container {
width: 50%;
border: 2px black solid;
box-sizing: border-box;
display: inline-flex;
position: relative;
}
<!DOCTYPE html>
<html>
<head>
<link href='style.css' rel='stylesheet'>
<link href="https://fonts.googleapis.com/css?family=Notable|Work+Sans&display=swap" rel="stylesheet">
</head>
<h1 id='main_title'>Website Style Specification - 1</h1>
<body>
<div class='container' id='color_container'>
<h2 class='sub'>Colours</h2>
<div class='color_box' id='color_one'>
<p>Coal</p>
<p>#252525</p>
<p>Background Colour</p>
</div>
<div class='color_box' id='color_two'>
<p>Blood</p>
<p>#ff0000</p>
<p>Text colour</p>
</div>
<div class='color_box' id='color_three'>
<p>Crimson</p>
<p>#af0404</p>
<p>Borders ad foreground colouring</p>
</div>
<div class='color_box' id='color_four'>
<p>Slate</p>
<p>#414141</p>
<p>Element background</p>
</div>
</div>
<div class='container' id='font_container'>
<h2 class='sub'>Fonts</h2>
<div class='font_box' id='font_1'>
<h3>Notable</h3>
<p class='normal'>This is how the text will display on the website.</p>
<p class='italic'>This is how the text will display on the website.</p>
<p class='bold'>This is how the text will display on the website.</p>
</div>
<div class='font_box' id='font_2'>
<h3>WorkSans-Regular</h3>
<p class='normal'>This is how the text will display on the website.</p>
<p class='italic'>This is how the text will display on the website.</p>
<p class='bold'>This is how the text will display on the website.</p>
</div>
</div>
<div class='container' id='text_styles'>
<h2 class='sub'>Text styles</h2>
<div class='text_box' id='text_1'>
<h3 id='sub_headings'>This is a sub heading</h3>
<ul>
<li>HTML: h2</li>
<li>font family: Notable</li>
<li>Font weight: 28px</li>
<li>Text decoration: underline</li>
</ul>
</div>
<div class='text_box' id='text_2'>
<p id='text'>
<ul>
<li>HTML: p</li>
<li>font family: Work sans</li>
<li>font weight: 18px</li>
</ul>
</p>
</div>
</div>
</body>
<footer></footer>
</html>
Are you looking for something like this?
Give the parent element of container display: flex and justify-content: center; and let flexbox do its magic. This will center the child elements on the X-Axis
* {
margin: 0;
padding: 0;
}
html {
display: block;
flex-direction: column;
width: 100%;
}
body{
width: 100%;
display: flex;
justify-content: center;
color: black;
}
h1 {
text-align: center;
}
.sub {
position: absolute;
}
.container {
width: 50%;
border: 2px black solid;
box-sizing: border-box;
text-align: center;
}
<html>
<body>
<div class="container">
HELLO IM THE CONTAINER
</div>
</body>
</html>
I am trying to apply flex to bootstrap 3 container and found strange behaviour of child elements Here is the code.
<div class="container">
<div class="child">One</div>
<div class="child">Two</div>
</div>
.container {
display: flex;
justify-content: space-between;
}
(see example on jsfiddle JSFiddle)
I cannot find out what's the problem with the space-between.
Thank you for the help.
Combining Bootstrap 3 with Flexbox is not recommended.
That said, Bootstraps container class also uses both the pseudo elements, hence they will participate in the flex container being flex items, and here one can see them when giving them a small width/height and background color.
And as you can see, the justify-content: space-between; work as it is supposed to.
.container {
display: flex;
justify-content: space-between;
}
.container::before, .container::after {
width: 30px;
height: 30px;
background: red;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="child">One</div>
<div class="child">Two</div>
</div>
One workaround would be a wrapper
.container .flex {
display: flex;
justify-content: space-between;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="flex">
<div class="child">One</div>
<div class="child">Two</div>
</div>
</div>
I think the issue is that you're using a classname from bootstrap .container you're attempting to change the style. Just use a id instead of the classname container.
#main {
display: flex;
justify-content: space-between;
}
<div id="main">
<div class="child">One</div>
<div class="child">Two</div>
</div>
I am trying to flank h1 tags inline with two instances of the same image on either side horizontally centered on the page. I have the following html:
<div id="divWnfsHeader">
<hr>
<div id="divH1ImgLeft"><img src="../images/transBg.png" alt="WNFS Image" /></div>
<div id="divH1"--><h1>WNFS</h1></div>
<div id="divH1ImgRight"><img src="../images/transBg.png" alt="WNFS Image" /></div>
</div><!-- close divWnfsHeader -->
And here is the CSS I have most recently tried:
#divH1 {
display: inline;
/*
overflow: hidden;
*/
}
#divH1ImgLeft {
display: inline;
float: left;
/*
overflow: hidden;
*/
}
#divH1ImgRight {
display: inline;
float: right;
/*
overflow: hidden;
*/
}
#divWnfsHeader {
text-align: center;
}
But of course it is not working or else I wouldn't be posting for help. I end up with the left image, indented and followed by a large gap and then the H1 content inline, and finally followed by the second instance of the same image on the next line, but perhaps it is actually on the same line but wrapped?
After trying multiple variations of different css params for the different divs detailed above I am still no further ahead. Could someone in the css-know please lend a hand and help my css along?
Simple way to do this is to use display: flex on parent and for hr you can use flex: 0 0 100% but on parent you should set flex-wrap: wrap then.
#divWnfsHeader {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
}
hr {
flex: 0 0 100%;
}
<div id="divWnfsHeader">
<hr>
<div id="divH1ImgLeft"><img src="../images/transBg.png" alt="WNFS Image" /></div>
<div id="divH1"--><h1>WNFS</h1></div>
<div id="divH1ImgRight"><img src="../images/transBg.png" alt="WNFS Image" /></div>
</div><!-- close divWnfsHeader -->
It can be done through bootstrap:
https://jsfiddle.net/896agnnx/
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 left"><img class="img-responsive" src="http://wmad.cs.vt.edu/images/code_background.png" alt="WNFS Image" /></div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 right"><img class="img-responsive" src="http://www.edgesolutions.in/wp-content/uploads/apps-development.jpg" alt="WNFS Image" /></div>
</div><!-- close divWnfsHeader -->
.left{
margin:0;
padding:0;
}
.right{
margin:0;
padding:0;
}
This question already has answers here:
How can I make Bootstrap columns all the same height?
(34 answers)
Closed 6 years ago.
How can I make two columns having the same height in Bootstrap grid columns?
.item-text {
padding: 30px !important;
/* Flex center. */
display: flex;
align-items: center;
vertical-align: middle;
justify-content: center;
border: 1px solid blue !important;
}
.item-text .item-center {
align-self: center;
margin: auto;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="col-xl-4 col-lg-6 col-sm-12">
<div class="col-sm-6">
<img src="http://placehold.it/400x600" class="img-responsive" alt="" />
</div>
<div class="col-sm-6 item-text">
<div class="item-center">
<h3 class="heading item-heading">(Title) Ways of Something</h3>
<p class="item-contributor">John Berger</p>
<p class="item-description">(Short description) Remix-remake of John Berger’s 1972 BBC documentary, Ways of Seeing</p>
</div>
</div>
</div>
Result:
Any ideas how to make the right column's height equal as the left one?
Add the following code to your CSS:
.row-eq-height {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
Then use that class on the row you want the column to have an equal height:
<div class="row row-eq-height">
<div class="col-lg-6"></div>
<div class="col-lg-6"></div>
</div>
That's it. This is the cleanest and more official way of doing it.
Try this:
Check Demo HERE
HTML:
<div class="row row-height">
<div class="col-sm-6">
<img src="http://placehold.it/400x600" class="img-responsive" alt="" />
</div>
<div class="col-sm-6 item-text">
<div class="item-center">
<h3 class="heading item-heading">(Title) Ways of Something</h3>
<p class="item-contributor">John Berger</p>
<p class="item-description">(Short description) Remix-remake of John Berger’s 1972 BBC documentary, Ways of Seeing</p>
</div>
</div>
</div>
CSS:
.row-height {
display: flex;
}
.item-text {
padding: 30px !important;
/* Flex center. */
display: flex;
align-items: center;
vertical-align: middle;
justify-content: center;
border: 1px solid blue !important;
}
.item-text .item-center {
/* align-self: center;
margin: auto; */
}