Is a "complex" matrix style grid powered by a css grid possible? - html

I am currently trying to achieve the following grid structure in Material-UI with a css grid:
Desired complex layout
I already created a css grid with Material-UI that looks like this:
Current layout
This is the code belonging to it:
import React from "react";
import clsx from "clsx";
import { makeStyles } from "#material-ui/core/styles";
import { Container } from "#material-ui/core";
const useStyles = makeStyles(theme => ({
container: {
marginTop: theme.spacing(8),
display: "grid",
gridTemplateColumns: "repeat(6, 56px)",
gridAutoRows: "56px",
gridGap: theme.spacing(0.5),
},
purple: {
background: "#e502f9",
color: "#ffffff",
height: "100%",
},
orange: {
background: "#f98202",
color: "#ffffff",
height: "100%",
gridColumnStart: "2",
},
lightGrey: {
background: "#d8d8d8",
height: "100%",
},
topLabel: {
gridColumnStart: "3",
gridColumnEnd: "span 4",
},
sideLabel: {
gridRowStart: "3",
gridRowEnd: "span 4",
writingMode: "vertical-rl",
transform: "rotate(180deg)",
},
align: {
alignItems: "center",
display: "flex",
justifyContent: "center",
textAlign: "center",
},
}));
function ExamplePage() {
const classes = useStyles();
return (
<Container component="main" maxWidth="xs">
<div className={classes.container}>
<div />
<div className={clsx(classes.topLabel, classes.align)}>
Text x-axis
</div>
<div className={clsx(classes.sideLabel, classes.align)}>
Text y-axis
</div>
<div />
<div />
<div className={clsx(classes.purple, classes.align)}>1</div>
<div className={clsx(classes.purple, classes.align)}>2</div>
<div className={clsx(classes.purple, classes.align)}>3</div>
<div className={clsx(classes.purple, classes.align)}>4</div>
<div className={clsx(classes.orange, classes.align)}>A</div>
<div className={clsx(classes.lightGrey, classes.align)}>4</div>
<div className={clsx(classes.lightGrey, classes.align)}>4</div>
<div className={clsx(classes.lightGrey, classes.align)}>4</div>
<div className={clsx(classes.lightGrey, classes.align)}>4</div>
<div className={clsx(classes.orange, classes.align)}>B</div>
<div className={clsx(classes.lightGrey, classes.align)}>3</div>
<div className={clsx(classes.lightGrey, classes.align)}>3</div>
<div className={clsx(classes.lightGrey, classes.align)}>3</div>
<div className={clsx(classes.lightGrey, classes.align)}>3</div>
<div className={clsx(classes.orange, classes.align)}>C</div>
<div className={clsx(classes.lightGrey, classes.align)}>2</div>
<div className={clsx(classes.lightGrey, classes.align)}>2</div>
<div className={clsx(classes.lightGrey, classes.align)}>2</div>
<div className={clsx(classes.lightGrey, classes.align)}>2</div>
<div className={clsx(classes.orange, classes.align)}>D</div>
<div className={clsx(classes.lightGrey, classes.align)}>1</div>
<div className={clsx(classes.lightGrey, classes.align)}>1</div>
<div className={clsx(classes.lightGrey, classes.align)}>1</div>
<div className={clsx(classes.lightGrey, classes.align)}>1</div>
</div>
</Container>
);
}
export default ExamplePage;
Does anybody also has an idea on how to programatically set the blue dot somewhere in the grid? I am not sure if this is possible at all in a css grid?

As #Michael_B stated, grid areas must be rectangular. Therefore, it's not possible to create a more complex layout.

Related

Owl Carousel not working in bootstrap modal

I have a parent page where I have a block of the list and in each list, I have images where on the image div I have implemented Owl Carousel and it is working fine.On each list the there is a button on clicking the button a modal will open and I want to implement Owl Carouse there but in the modal Owl carousel is not working as expected.
In main page I have implement Owl like this
$(".owl-carousel").owlCarousel({
loop: false,
autoPlay: false,
stopOnHover: false,
navigation: true,
pagination: false,
paginationNumbers: false,
responsiveClass: true,
//loop: true,
//margin: 10,
//nav: true,
responsive: {
0: {
items: 2
},
600: {
items: 2
},
1000: {
items: 3
},
1360: {
items: 3
}
}
});
And in Modal I have implemented Owl like this
$('#package-details').on('shown.bs.modal',
function () {
debugger;
$("#pckg-app-list").owlCarousel({
loop: false,
autoPlay: false,
stopOnHover: false,
navigation: true,
pagination: false,
paginationNumbers: false,
responsiveClass: true,
responsive: {
0: {
items: 2
},
600: {
items: 2
},
1000: {
items: 3
},
1360: {
items: 3
}
}
});
});
In modal Owl is generated this way in HTML which is wrong because there is no outer elemnt applying.
<div class="owl-carousel owl-theme yesscroll px-0 owl-loaded owl-drag" id="pckg-app-list"><div class="item"> <img class="owlimage" src="https://appsdrive.blob.core.windows.net/applogos/aeb6cee7-3951-4fe6-af63-f656b2a8bdb9_SAp-business-one.png"> </div><div class="item"> <img class="owlimage" src="https://appsdrive.blob.core.windows.net/applogos/3334f37d-bd1e-419a-89bc-28544ddb4e8c_magento.png"> </div></div>
function showModal() {
$('.modal').on('show.bs.modal', function (event) {
$('.owl-carousel').owlCarousel({
loop: true,
margin: 10,
nav: true,
navText: [
"<i class='fa fa-caret-left'></i>",
"<i class='fa fa-caret-right'></i>"
],
autoplay: true,
autoplayHoverPause: true,
responsive: {
0: {
items: 1
},
600: {
items: 3
},
1000: {
items: 5
}
}
})
})
$(".modal").modal("show");
}
.carousel-wrap {
margin: 90px auto;
padding: 0 5%;
width: 80%;
position: relative;
}
/* fix blank or flashing items on carousel */
.owl-carousel .item {
position: relative;
z-index: 100;
-webkit-backface-visibility: hidden;
}
/* end fix */
.owl-nav > div {
margin-top: -26px;
position: absolute;
top: 50%;
color: #cdcbcd;
}
.owl-nav i {
font-size: 52px;
}
.owl-nav .owl-prev {
left: -30px;
}
.owl-nav .owl-next {
right: -30px;
}
.btn-modal-close {
width: 32px;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.1/dist/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.1.3/assets/owl.carousel.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script src="https://use.fontawesome.com/826a7e3dce.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.1.3/owl.carousel.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.6.1/dist/js/bootstrap.bundle.min.js"></script>
<a class="btn btn-primary" href="javascript:void(0);" onclick="showModal()">Click Here</a>
<div class="modal" tabindex="-1">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-body">
<div class="d-flex justify-content-center mb-2 justify-content-md-end">
<button type="button" class="close btn-modal-close" data-dismiss="modal" aria-label="Close">
<span>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 29.24 29.24">
<g fill="none" stroke="#52bbab" stroke-miterlimit="10">
<path d="m28.22 28.88-27.87-27.86" />
<path d="m.35 28.88 28.53-28.53" />
</g>
</svg>
</span>
</button>
</div>
<div class="container-fluid">
<div class="carousel-wrap">
<div class="owl-carousel">
<div class="item"><img src="http://placehold.it/150x150"></div>
<div class="item"><img src="http://placehold.it/150x150"></div>
<div class="item"><img src="http://placehold.it/150x150"></div>
<div class="item"><img src="http://placehold.it/150x150"></div>
<div class="item"><img src="http://placehold.it/150x150"></div>
<div class="item"><img src="http://placehold.it/150x150"></div>
<div class="item"><img src="http://placehold.it/150x150"></div>
<div class="item"><img src="http://placehold.it/150x150"></div>
<div class="item"><img src="http://placehold.it/150x150"></div>
<div class="item"><img src="http://placehold.it/150x150"></div>
<div class="item"><img src="http://placehold.it/150x150"></div>
<div class="item"><img src="http://placehold.it/150x150"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

React Bootstrap container different sizing to regular HTML Bootstrap

Why does the Bootstrap container component size differently than a regular HTML Bootstrap, not sure if I am missing a prop or not?
This is what I get the output I get for both:
(the white space in the sides are from the container margin)
React code:
<Container>
<Row className="row">
<Col className="col-lg-3 col-md-4">
<div
style={{ width: "100%", height: "100vh", backgroundColor: "blue" }}
></div>
</Col>
<div className="col-lg-9 col-md-8 tab-container">
<div
style={{ width: "100%", height: "100vh", backgroundColor: "red" }}
></div>
</div>
</Row>
</Container>
Regular HTML code:
<div class="container">
<div class="row">
<div class="col-lg-3 col-md-4">
<div style="width: 100%; height: 100vh; background-color: blue"></div>
</div>
<div class="col-lg-9 col-md-8">
<div style="width: 100%; height: 100vh; background-color: red"></div>
</div>
</div>
</div>
Can someone help with the correct styling/fix for the React version to match the regular one please?

Get properly sized brand logos in a carousel

I'm trying to achieve an automatic resizing of different brand logos for a company website I'm designing, inside an Own Carousel. The idea is for each logo to be of reasonable size.
Most of the logos are in SVG formats, available at https://wetransfer.com/downloads/44eb123d186e30519edc2d025dafd03420200110231646/112373 (for a week) : as you would see, they have a wide range of height / width ratio, so using a fixed-width and enforcing the correct ratio made some of them (the CNRS and CEA logos) too high.
The goal (taken from a random site):
The goal
What I got:
What I got
My code (HTML, then CSS based on Bootstrap 4, then the JS snippet that uses owl-carousel):
<div class="site-section">
<div class="container">
<div class="row justify-content-center text-center mb-5">
<div class="col-md-5">
<h2 class="section-heading">Ils nous ont fait confiance</h2>
</div>
</div>
<div class="row justify-content-center text-center">
<div class="col">
<div class="owl-carousel clients-carousel">
<img src="./img/clients/airbus-group.svg" class="client-logo limit-width" />
<img src="./img/clients/safran-group.png" class="client-logo limit-width" />
<img src="./img/clients/cnrs-fr.svg" class="client-logo limit-height" />
<img src="./img/clients/cea-fr.svg" class="client-logo limit-height" />
<img src="./img/clients/bic.svg" class="client-logo limit-width" />
<img src="./img/clients/edf.svg" class="client-logo limit-width" />
<img src="./img/clients/horiba.svg" class="client-logo limit-width" />
<img src="./img/clients/jenoptec-group.svg" class="client-logo limit-width" />
<img src="./img/clients/otis.svg" class="client-logo limit-width" />
<img src="./img/clients/thales.svg" class="client-logo limit-width" />
</div>
</div>
</div>
</div>
</div>
.clients-carousel .owl-stage-outer, .clients-carousel .owl-stage, .clients-carousel .owl-item {
display: flex;
}
.clients-carousel .owl-item {
margin-left: 1rem;
margin-right: 1rem;
}
.clients-carousel .owl-item img.client-logo {
width: 15em;
height: auto;
}
var siteOwlCarousel = function() {
$('.clients-carousel').owlCarousel({
center: true,
items: 3,
loop: true,
margin: 0,
autoplay: true,
smartSpeed: 1000,
nav:false,
dots:false,
autoWidth:true,
responsive: {
// breakpoint from 0 up
0 : {
items: 3
},
// breakpoint from 576 up
576 : {
items: 3
},
// breakpoint from 768 up
768 : {
items: 4,
center: false
},
992 : {
items: 4,
center: false
},
1200 : {
items: 4,
center: false
}
}
});
};
siteOwlCarousel();
Would somebody have an idea that relies on Flexbox?
Thanks in advance!
choumat
Change .owl-wrapper display property and owl-item display, float, vertical-align properties and set to max- width & height size.
I hope below snippet will help you lot.
var siteOwlCarousel = function() {
$('.clients-carousel').owlCarousel({
center: true,
items: 3,
loop: true,
margin: 10,
autoplay: true,
smartSpeed: 1000,
nav: false,
dots: false,
autoWidth: true,
responsive: {
0 : {
items: 2
},
576 : {
items: 3
},
768 : {
items: 4
},
992 : {
items: 4
},
1200 : {
items: 4
}
}
});
};
siteOwlCarousel();
.owl-carousel .owl-wrapper {
display: table!important;
}
.owl-carousel .owl-item {
display: table-cell!important;
float: none!important;
vertical-align: middle!important;
}
.clients-carousel .owl-item .item{
text-align: center!important;
padding: 15px 30px!important;
}
.clients-carousel .owl-item img{
max-width: 180px!important;
max-height: 50px!important;
display: inline-block!important;
}
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"></script>
<div class="site-section">
<div class="container">
<div class="row justify-content-center text-center mb-5">
<div class="col-md-5">
<h2 class="section-heading">Ils nous ont fait confiance</h2>
</div>
</div>
<div class="row justify-content-center text-center">
<div class="col">
<div class="owl-carousel clients-carousel">
<div class="item"><img src="./img/clients/airbus-group.svg"></div>
<div class="item"><img src="./img/clients/safran-group.png"></div>
<div class="item"><img src="./img/clients/cnrs-fr.svg"></div>
<div class="item"><img src="./img/clients/cea-fr.svg"></div>
<div class="item"><img src="./img/clients/bic.svg"></div>
<div class="item"><img src="./img/clients/edf.svg"></div>
<div class="item"><img src="./img/clients/horiba.svg"></div>
<div class="item"><img src="./img/clients/jenoptec-group.svg"></div>
<div class="item"><img src="./img/clients/otis.svg"></div>
<div class="item"><img src="./img/clients/thales.svg"></div>
</div>
</div>
</div>
</div>
</div>

<div> not using full bootstrap column space

I am trying to make three buttons use the full width of a column.
The grid is 3 for the buttons and 9 for other components.
Here's a visual. So basically the buttons should also occupy the space that's marked with red, they should just use the whole column of 3.
Here's App.js where I imported the component:
<div className="container-full padding-0" style={{overflow:'hidden', overflowY:'hidden'}}>
<div className="row">
<div className="col-sm-3" style={{borderRight:"1px solid #000"}}>
<div className="row no-gutters mt-auto">
<div className="col-sm-3">
<COMPONENT1/>
</div>
<div className="col-sm-9">
<COMPONENT2/>
</div>
</div>
<COMPONENT3 store={store} style={{overflow:'hidden'}}/>
<COMPONENT4/>
<BUTTONS/> --------------------------> Here are the buttons
</div>
<div className="col-sm-9" style={{paddingRight: 0, paddingLeft: 0}}>
<COMPONENT6 = {store} style={{overflow:'hidden'}}/>
<br/>
<COMPONENT7/>
<COMPONENT8 store={store} clicked={this.clicked}/>
</div>
</div>
</div>
And buttons component:
<div className="row no-gutters mt-auto" style={{paddingTop:10}}>
<div className="col-sm-4">
<Button variant="raised" style={buttonStyle}>A</Button>
</div>
<div className="col-sm-4">
<Button variant="raised" style={buttonStyle}>B</Button>
</div>
<div className="col-sm-4">
<Button variant="raised" style={buttonStyle}>C</Button>
</div>
</div>
And the css for the buttons:
const buttonStyle = {
fontSize: 20,
textAlign: 'center',
display:'inline-block',
width:'100%',
height:100
}
EDIT: Here's a quick pic of the UI
Can you please try the following method:
Give below css rules to row no-gutters mt-auto:
style={{ display: 'flex', flex: 1, flexDirection: 'row' }}
It will work for sure !
Thanks

How to make images in grid to grow vertically when changing browser width?

Here is the example I am trying to achieve
I want left and right image to always be the same height, and height of the block in the middle should be equal to the height of the left image.
Even more I need images to grow vertically when I change browser width.
I am stuck and not sure how to achieve such result. Instead of images I could utilize div elements with the background.
Specifically I am not sure how to make image heights of the inner block to grow in height with the browser width, and I do not want to use JavaScript to achieve such result
In my current efforts I can make all the columns to be the same height, however, when I change browser width there is more space added between columns.
So I was able to achieve meaningful result with the div blocks and background images
const drDefaultStyles = {
container: {
},
header: {
borderBottom: 'solid 1px #dddddd',
color: '#898989',
textAlign:'left',
marginBottom: '20px',
},
header_title: {
fontSize: '14px',
fontStyle: 'italic',
fontFamily: 'Platino',
textTransform: 'capitalize',
margin: 0,
fontWeight: 100,
},
tall: {
height: '250px',
},
half_tall: {
height: '120px',
},
image_container: {
position: 'relative',
width: '100%',
height: '100%',
background: 'rgb(245, 245, 245)',
padding: '10px',
},
image: {
width: '100%',
height: '100%',
backgroundSize: 'cover',
backgroundPosition: 'center center',
backgroundRepeat: 'no-repeat',
},
title: {
position: 'absolute',
display: 'inline-block',
bottom: '25px',
background: 'rgba(245, 245, 245, .85)',
textTransform: 'uppercase',
padding: '7px 15px',
},
}
<section className="container" style={ _s.container }>
<div className="row" style={ _s.header }>
<h2 style={ _s.header_title }>Destination races</h2>
</div>
<div className="row" style={ _s.container }>
<div className="col-lg-4 col-md-4 col-sm-4 col-xs-4" style={{ ..._s.tall, paddingLeft: 0, paddingRight: '5px' }}>
<div style={ _s.image_container }>
<div style={{ ..._s.image, backgroundImage: 'url(/images/cities/leadville.jpg)' }}></div>
<span style={ _s.title }>Leadville</span>
</div>
</div>
<div className="col-lg-4 col-md-4 col-sm-4 col-xs-4" style={{ padding: 0 }}>
<div className="col-lg-12 col-md-12 col-sm-12 col-xs-12" style={{ ..._s.half_tall, marginBottom: '10px', padding: 0 }}>
<div style={ _s.image_container }>
<div style={{ ..._s.image, backgroundImage: 'url(/images/cities/san-francisco.jpg)' }}></div>
<span style={ _s.title }>San Francisco</span>
</div>
</div>
<div className="col-lg-5 col-md-5 col-sm-5 col-xs-5" style={{ ..._s.half_tall, float: 'left', padding: 0, paddingRight: '5px' }}>
<div style={ _s.image_container }>
<div style={{ ..._s.image, backgroundImage: 'url(/images/cities/miami.jpg)' }}></div>
<span style={ _s.title }>Miami</span>
</div>
</div>
<div className="col-lg-7 col-md-7 col-md-7 col-xs-7" style={{ ..._s.half_tall, float: 'left', padding: 0 }}>
<div style={ _s.image_container }>
<div style={{ ..._s.image, backgroundImage: 'url(/images/cities/chicago.jpg)' }}></div>
<span style={ _s.title }>Chicago</span>
</div>
</div>
</div>
<div className="col-lg-4 col-md-4 col-sm-4 col-xs-4" style={{ ..._s.tall, paddingLeft: '5px', paddingRight: 0 }}>
<div style={ _s.image_container }>
<div style={{ ..._s.image, backgroundImage: 'url(/images/cities/new-york.jpg)' }}></div>
<span style={ _s.title }>New York City</span>
</div>
</div>
</div>
</section>