Asked
Viewed24 times
using Bootstrap 5 I want to display a div and a canvas on on a row till md
as a Breakpoint
I want to alling the canvas right after the text ends at the moment each part has an equal width
How can I remove the unused space from the div?
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
crossorigin="anonymous"
/>
<section class="p-5">
<div class="container">
<div class="row g-4 bg-primary">
<div class="col-md-6">
<div>
<p>
first stuff
<span>hi</span>
</p>
<p>
second stuff
<span>hii</span>
</p>
<p>
third stuff
<span>hiii</span>
</p>
<p>global stuff <span>hello</span></p>
</div>
</div>
<div class="col-md-6 bg-dark">
<canvas></canvas>
</div>
</div>
</div>
</section>
Replace Class col-md-6
thaw <div class="col-md-auto">
& <div class="col bg-dark">
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
crossorigin="anonymous"
/>
<section class="p-5">
<div class="container">
<div class="row g-4 bg-primary">
<div class="col-md-auto">
<div>
<p>
first stuff
<span>hi</span>
</p>
<p>
second stuff
<span>hii</span>
</p>
<p>
third stuff
<span>hiii</span>
</p>
<p>global stuff <span>hello</span></p>
</div>
</div>
<div class="col bg-dark">
<canvas></canvas>
</div>
</div>
</div>
</section>
You just need to change the size written after md of colon property of both the classes and. I am also providing the code below:
<html>
<head>
<!--<meta name="viewport" content="with=device-width, initial-scale=1.0">-->
<title>Header</title>
<link rel="stylesheet" href="style.css" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link href="https://fonts.googleapis.com/css2?
family=Montserrat:wght@300;500;700&display=swap rel="stylesheet">
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
crossorigin="anonymous"
/>
</head>
<body>
<section class="p-5">
<div class="container">
<div class="row g-3 bg-primary">
<div class="col-md-3">
<div>
<p>
first stuff
<span>hi</span>
</p>
<p>
second stuff
<span>hii</span>
</p>
<p>
third stuff
<span>hiii</span>
</p>
<p>global stuff <span>hello</span></p>
</div>
</div>
<div class="col-md-9 bg-dark">
<canvas></canvas>
</div>
</div>
</div>
</section>
Vibhor Goyal is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
lang-html