我正在尝试使用工具栏创建一个“文本区域”,以基于背景中存储在文本区域中的html内容显示富文本内容。 html就是这样:
<div class="primary-content">
<div class="textarea-with-nav" id="outerWrap">
<div class="navbar">
<ul>
<li><a href="#">teste1</a></li>
<li><a href="#">teste2</a></li>
<li><a href="#">teste3</a></li>
</ul>
</div>
<textarea id="layer1"></textarea>
<textarea id="layer2"></textarea>
</div>
</div>
现在具有CSS样式的
html,body {
margin: 0;
height: 100%;
}
.primary-content {
padding-top: 55px;
}
.navbar {
grid-area: header;
overflow: hidden;
background-color: #333;
width: 100%;
z-index: 1;
}
.navbar.site-nav {
position: fixed;
top: 0;
}
.navbar ul { list-style-type: none; }
.navbar ul li { display: inline; }
.navbar ul li a {
color: white;
padding: 8px 16px;
text-decoration: none;
}
.navbar ul li a:hover {
background-color: #555;
color: white;
height: 100%;
}
.textarea-with-nav {
transform: translate(50%);
width: 400px;
height: 300px;
position: realtive;
border-radius: 5px;
border: 1px solid #ccc;
}
.textarea-with-nav > .navbar {
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}
.textarea-with-nav > textarea {
border: none;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
width: 396px !important;
height: 246px !important;
resize: none;
}
.textarea-with-nav > textarea:focus { outline: none; }
#outerWrap {
position: relative;
z-index: 0;
}
#layer1 {
position: absolute;
z-index: 1;
}
#layer2 {
position: absolute;
z-index: 2;
}
调整layer2
(前面的那个)的大小时,应同时调整两个文本区域的大小(而layer1
可能不是最终版本中的文本区域)。
此外,如果我水平调整textareas的大小,导航栏也应伸展,以跟踪textarea的新尺寸。
有人知道如何实现这一目标吗?这是否需要一些javascript代码,还是只需要CSS即可?