gpt4 book ai didi

javascript - Css - 是否可以在调整屏幕大小时移动元素以使其适合屏幕

转载 作者:太空宇宙 更新时间:2023-11-04 12:15:38 25 4
gpt4 key购买 nike

这是代码的链接 - link to jsfiddle

这是代码-

    <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>


<style>
.can_con {
border: 1px solid #b6ff00;
position: absolute;
top: 25px;
left: 600px;

}

li {
font-size: 60px;

}

</style>
</head>
<body>

<ul>
<li>Some Text 1</li>
<li>Some Text 2</li>
<li>Some Text 3</li>
</ul>

<div class="can_con">
<canvas id="#myCan" width="600" height="200" style="border:1px solid #f00;"></canvas>
</div>


</body>
</html>

现在我想知道的是,有没有办法让 Canvas 元素在屏幕放大时不消失。

我的意思是当前状态是 Canvas 元素移到屏幕的右侧,我想避免这种情况。

谢谢你的帮助

最佳答案

您可以使用 floatbox-sizing

.can_con {
width:50%;
float:right;
box-sizing: border-box;
}
.can_con canvas{
width:100%;
display:block
}
ul {
width:50%;
float:left;
box-sizing: border-box;
}
li {
font-size: 60px;
}

并删除 widthheight来自 <canvas>标签

<canvas id="#myCan" style="border:1px solid #f00;"></canvas>

更新 fiddle :http://jsfiddle.net/7pt6uw53/4/

关于javascript - Css - 是否可以在调整屏幕大小时移动元素以使其适合屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28739260/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com