+ 1
why "width" is not working while using position:fixed?
change static into fixed then width will not work. why is this happening? what is the solution? https://code.sololearn.com/WRP2NYcV5nO5/?ref=app
7 Respostas
+ 2
Width does not have a [max] value
https://www.w3schools.com/css/css_dimension.asp
"A div is a block-level element that always starts on a new line and takes up the full width available (stretches out to the left and right as far as it can)." w3schools.com
Hence the reason for the line crossing the screen.
I'm not sure why, but when you change the position of the element to fixed, the width is set to how much the element needs. But setting the width to 100% should solve your problem
https://code.sololearn.com/WbkyCc6j2WEY/#html
+ 2
No problems, I'm glad I could help.
+ 1
Try:
position:relative;
+ 1
Thanks bro, it has worked 😘
0
Marzan It has worked, but I wanna fix it. I mean I don't want it to be scrolled. what to do?
Gordon Fatima Tuz Johra
0
Because it's position is fixed
- 1
<html>
<head>
<style>
.bo {
padding:0;margin:0;
height:1000px;
}
.po{background-color:red; height:50px; width:100%; border-bottom: 2px solid pink; position:fixed;top:0;}
</style>
</head>
<body class="bo">
<div class="po">
<a href="link"><img src="image.jpg" width="15px" height="15px" alt="pho"></a>
</div>
</body>
</html>