Issue
I'm having trouble opening my modal window, when I open it the styles make it look very small. specifically this style that affects all HTML makes my modal window look very small
html {
font-size: 62.5%;
overflow-x: hidden;
scroll-padding-top: 7rem;
scroll-behavior: smooth;
}
The 'font-zise: 62.5%' makes the modal window look very small but I can't remove that style because all other styles on the page depend on it and everything else on the page looks very ugly.
This is the modal window:
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
Help, I want you to find a way to make the style "font-size: 62.5%;" I'm not affected by the modal window but everything else in the HTML.
I tried to apply the style to the body tag and not put the modal window in the body but it didn't work.
Solution
In order to to that, the css style should exclude elements of the modal.
For example
html :not(.modal *){
font-size: 62.5%;
overflow-x: hidden;
scroll-padding-top: 7rem;
scroll-behavior: smooth;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal">
Launch demo modal
</button>
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
Answered By - Epic Chen
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.