javascript - 这种评论表单的布局是怎么做出来的?
问题描述
这是简书的评论表单:
我的 html 结构如下:
<form action='' method='post'> <a href='https://www.haobala.com/wenda/3430.html' class='avatar'><img src='https://www.haobala.com/wenda/images/avatar.jpg' alt=''></a> <textarea placeholder='写下你的评论...'></textarea> <footer><span>Ctrl + Return 发表</span><button type='reset'>取消</button><button type='submit'>发送</button> </footer></form>
我设置头像 .avatar 元素左浮动,然后设置 textarea 的 width=100%,但是这样设置后 textarea 会新起一行,无法达到想要的效果。我想实现简书这样的布局该怎么设置 css 样式?
问题解答
回答1:= =题主不会照搬其样式么?form设置relative,头像设置absolute……
关键词:绝对定位


.avatar { margin-right: -50px; float: left;}textarea { display: block; width: 100%; margin-left: 50px;}
以上按照你的思路来的,其实要实现这种分栏布局方法有很多种,BFC、absolute、flex 都可以。
回答3:<form action='' method='post'>
<p style='width:20%;float:left'> <a href='https://www.haobala.com/wenda/3430.html' class='avatar'><img src='https://www.haobala.com/wenda/images/avatar.jpg' alt=''></a></p><p style='width:80%;float:right'> <textarea placeholder='写下你的评论...'></textarea> <footer><span>Ctrl + Return 发表</span><button type='reset'>取消</button><button type='submit'>发送</button> </footer></p>
</form>
回答4:代码先写4 后写5

相关文章:
1. mysql根据输入的字段数据获取到ID怎么解决??2. 数据库 - mysql中怎样修改带点的字段名的位置?3. 乱码 - VS2013+PTVS,python编码问题4. 网页爬虫 - 关于python3.x 编写爬虫异常问题请各位大神帮忙!5. mysql - 求一个sql语句,比较简单。6. linux - 编译安装mysql 5.6.237. html - Python2 BeautifulSoup 提取网页中的表格数据及连接8. MYSQL中如何把SELECT A AS B中的B作为WHERE筛选条件9. python - 字符串中反斜杠的替换10. centos下mysql启动报错

网公网安备