আমরা CSS max-width প্রপার্টি ব্যবহার করে একটি উপাদানের কন্টেন্ট বক্সের জন্য একটি নির্দিষ্ট সর্বোচ্চ-প্রস্থ নির্ধারণ করতে পারি যা উপাদানের কন্টেন্ট বক্সকে প্রশস্ত করার অনুমতি দেয় না যদিও প্রস্থ সর্বোচ্চ-প্রস্থের চেয়ে বেশি হয়।
সিনট্যাক্স
CSS সর্বাধিক-প্রস্থ সম্পত্তির সিনট্যাক্স নিম্নরূপ -
Selector {
max-width: /*value*/
} চলুন CSS max-width প্রপার্টি -
-এর একটি উদাহরণ দেখিউদাহরণ
<!DOCTYPE html>
<html>
<head>
<title>CSS max-width Property</title>
</head>
<style>
* {
padding: 2px;
margin:5px;
}
button {
border-radius: 10px;
}
#containerDiv {
width:70%;
margin: 0 auto;
padding:20px;
background-image: linear-gradient(135deg, #dc3545 0%, #9599E2 100%);
text-align: center;
border-radius: 10px;
}
#contentDiv{
max-width:200px;
overflow: hidden;
}
</style>
<body>
<div id="containerDiv">
<div id="contentDiv">
This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text.
</div>
<button onclick="add()" class="btn">Set maxWidth</button>
</div>
<script>
function add() {
document.querySelector('#contentDiv').style.maxWidth = "100%";
}
</script>
</body>
</html> আউটপুট
'Set maxWidth' ক্লিক করার আগে৷ বোতাম -

'Set maxWidth' ক্লিক করার পরে৷ বোতাম -

চলুন CSS max-width প্রপার্টি −
-এর আরেকটি উদাহরণ দেখিউদাহরণ
<!DOCTYPE html>
<html>
<head>
<title>CSS max-width Property</title>
</head>
<style>
* {
padding: 2px;
margin:5px;
}
button {
border-radius: 10px;
}
#containerDiv {
width:70%;
margin: 0 auto;
padding:20px;
background-image: linear-gradient(135deg, #dc3545 0%, #9599E2 100%);
text-align: center;
border-radius: 10px;
}
#contentDiv1, #contentDiv2{
width:100%;
border: 1px solid black;
margin: 0 auto;
}
#contentDiv2{
width: 80%;
}
</style>
<body>
<div id="containerDiv">
<div id="contentDiv1">
This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text.
</div>
<div id="contentDiv2">
This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy.
</div>
<button onclick="add()" class="btn">Set maxWidth</button>
</div>
<script>
function add() {
document.querySelector('#contentDiv1').style.maxWidth = "80%";
}
</script></body></html> আউটপুট
'Set maxWidth' ক্লিক করার আগে৷ বোতাম -

'Set maxWidth' ক্লিক করার পরে৷ বোতাম -
