当前位置: 首页 > news >正文

前端css样式设置元素的绝对定位和相对定位,要注意宽度和高度的设置

vue3子div position absolute,父div positon relative 。如果不设置子div的 width 和height,那么子div中如果数据变长,子div相对父div位置会变化。子div数据超过,显示... 如何实现

<template><div class="parent"><div class="child">{{ dynamicContent }}</div></div></template><script>export default {data() {return {dynamicContent: "这是一666666666个动态内容,可以很长很长6666666666"};}};</script><style scoped>.parent {position: relative;width: 200px;height: 100px;border: 1px solid #000;}.child {position: absolute;text-align: center;top: 40%;width: 21%;left: 0;background: pink;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;}</style>
如果同时设置宽度和高度

此时如果不设置宽度,设置高度 显示效果

设置宽度,不设置高度 显示效果


http://www.mrgr.cn/news/39770.html

相关文章:

  • 一条命令Docker安装常用桌面linux系统含一些系统和应用
  • 数据结构(链表的操作算法)
  • 不带头结点单链表逆置递归实现---未验证
  • 如何选择合适的量化交易策略,回测与模拟交易的实战演练
  • java-netty客户端断线重启0.9.0
  • Vim常见模式介绍,你知道哪些?
  • find()和findIndex()方法
  • Navicat 工具 下载安装
  • TE-1402/1403 简易使用说明 - Technica Engineering Media Converter
  • Spring Task 调度任务
  • 【Leecode 随笔】C语言版看了不后悔系列持续更新中。。。
  • Excel表格还能这样玩?没有VBA和插件,一样可以用数据库功能
  • 什么是javascript的事件循环
  • WebRTC入门
  • 这几种文件找回方法你都知道吗?
  • vue3+typescript 如何将xml格式的文件转化成key value的形式?
  • scrapy 爬取微博(五)【最新超详细解析】: 爬取微博文章
  • 【2024.9.30练习】素数密度
  • 阿里云表格存储OtsQueryWrapper
  • Nginx部署前端Vue项目的深度解析