Reputation: 15
Is there any way to use max-width on elements other than images? Or any similar property that helps texts dynamically size itself to the browser window?
Upvotes: 0
Views: 142
Reputation: 5309
Please refer the fiddle.
<div></div>
takes the full width.
or
You can provide max-width
for the div
Upvotes: 0
Reputation: 791
Every block elements support max-width. for dynamic fonts sizing things relative to the current viewport size css3 have vw
, vh
, and vmin
.
you can refer css-tricks, sitepoint.
I hope this may helps you.
Upvotes: 0
Reputation: 892
All the elements of display type block automatically get width according to their parent element. However in order to change text size when you increase or decrease the width of your window, you will have to apply media queries. See below code.
.x{
font-size:14px;
}
@media screen and (max-width:991px){
.x{
font-size:13px;
}
}
@media screen and (max-width:768px){
.x{
font-size:12px;
}
}
@media screen and (max-width:440px){
.x{
font-size:11px;
}
}
Here x
is some arbitrary element whose font size you need to adjust.
Upvotes: 1