Javascript 如何将文本作为背景添加到html?
现在我有一个带换行符、分词符的div,还有一行随机创建的0和1填充了背景。它看起来不错,但是长度是固定的,并且在不同的屏幕尺寸下太长/太短Javascript 如何将文本作为背景添加到html?,javascript,html,text,background,Javascript,Html,Text,Background,现在我有一个带换行符、分词符的div,还有一行随机创建的0和1填充了背景。它看起来不错,但是长度是固定的,并且在不同的屏幕尺寸下太长/太短 有没有更好的办法?我只想要一个0和1的书呆子背景 可以对文本使用position属性position:absolute,而文本包装器属性position:relative 要全屏显示文本区域: <!DOCTYPE html> <html> <body> <textarea na
有没有更好的办法?我只想要一个0和1的书呆子背景 可以对文本使用position属性position:absolute,而文本包装器属性position:relative 要全屏显示文本区域:
<!DOCTYPE html>
<html>
<body>
<textarea name="text1" style="width: 100%;height: 100%"></textarea>
</body>
</html>
如果您想成为输入用户,则无法编辑大小:
<!DOCTYPE html>
<html>
<body>
<input type="search" style="width: 100%;height: 100%" >
</body>
</html>
可以将div与其他样式属性一起使用
您可以在此处播放和测试它:谢谢,小提琴帮助我跟踪错误。“高度”属性在我的项目中不起作用,但在小提琴中起作用。原因是我没有在父元素中指定高度。
.background {
overflow-x: hidden; // hide scroll-x
overflow-y: hidden; // hide scroll-y
word-wrap: break-word; // word wrap text
width:97%; // width > 97% absolut position div will overflow and cause screen scroll
height:97%; // height > 97% absolut position div will overflow and cause screen scroll
position: absolute; // this way the div will act as background and it will not interfier with the rest of the components in the html
}