I'm using bootstrap 5. I want to use an img
tag to display a different image for mobile/tablet/desktop. I'm trying with this code but I'm unable to set correctly the breakpoints for the wrapper divs using the display
utilities of the bootstrap framework.
If is possible, I want to have three image tags instead of three different divs that take the 100% of the window height.
If you see the code, I have a sort of modal to display on top of the background image that needs to fit for each breakpoint all the screen space available. I've tried with img-fluid w-100 h-100
classes but the result isn't really nice and I can't crop the background. I'm using vue for the front-end, I'm not a front-end dev.
Thank you.
<template>
<div class="container-fluid p-0">
<div class="row m-0">
<!-- This div with the image needs to be displayed only on mobile sm breakpoint -->
<div class="col-lg-12 d-md-none d-lg-none d-sm-block p-0">
<img class="img-fluid w-100" src="@/assets/sm-background.png">
</div>
<!-- This div with the image needs to be displayed only on tablet md breakpoint -->
<div class="col-lg-12 d-none d-sm-none d-lg-none d-md-block p-0">
<img class="img-fluid w-100" src="@/assets/md-background.png">
</div>
<!-- This div with the image needs to be displayed only on desktop lg breakpoint -->
<div class="col-lg-12 d-none d-sm-none d-md-none d-lg-block p-0">
<img class="img-fluid w-100" src="@/assets/lg-background.png">
</div>
<div class="col-sm-12 col-md-6 col-lg-6 mx-auto position-absolute" id="checkModal">
<div class="card">
<div class="card-body">
<h4>Age verification required</h4>
<p>...</p>
<input type="date" class="form-control" v-model="birthDate" >
<input type="passwrd" class="form-control" v-model="passwor" >
<button class="btn btn-primary" @click.prevent="unlockContent()">Conferma</button>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'App',
data() {
return {
birthDate: '',
password: ''
}
},
mounted() {
},
methods: {
unlockContent() {
console.log(this.birthDate, this.password);
}
}
}
</script>
<style>
/* #app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
} */
#checkModal {
top: 14%;
left: 0;
right: 0;
z-index: 1;
}
</style>
´``