国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

筆記:dom元素各種寬度和高度,getBoundingClientRect,clientWidth,clientHeight,offsetWidth,offsetHeight

這篇具有很好參考價(jià)值的文章主要介紹了筆記:dom元素各種寬度和高度,getBoundingClientRect,clientWidth,clientHeight,offsetWidth,offsetHeight。希望對大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

HTMLElement.getBoundingClientRect

Element.getBoundingClientRect()

返回值是一個(gè)DOMRect對象,是包含整個(gè)元素的最小矩形(包括 padding 和 border-width)。該對象使用left、top、right、bottom、x、y、width 和 height這幾個(gè)以像素為單位的只讀屬性描述整個(gè)矩形的位置和大小。除了 width 和 height 以外的屬性是相對于視圖窗口的左上角來計(jì)算的。

該方法返回的 DOMRect 對象中的 width 和 height 屬性是包含了 padding 和 border-width 的,而不僅僅是內(nèi)容部分的寬度和高度。

在標(biāo)準(zhǔn)盒子模型中,這兩個(gè)屬性值分別與元素的 width/height + padding + border-width 相等。

而如果是 box-sizing: border-box,兩個(gè)屬性則直接與元素的 width 或 height 相等。

通過getBoundingClientRect獲取的屬性值是不計(jì)算滾動(dòng)偏移量的,是相對瀏覽器可視區(qū)域而言的。

dom的寬度,開發(fā)記錄,css,css3,前端

.box {
  background-color: palevioletred;
  height: 200px;
  width: 200px;
}

dom的寬度,開發(fā)記錄,css,css3,前端

.box {
  background-color: palevioletred;
  height: 200px;
  width: 200px;
  padding: 20px;
  border: 10px solid green;
}

dom的寬度,開發(fā)記錄,css,css3,前端
dom的寬度,開發(fā)記錄,css,css3,前端

.box {
  background-color: palevioletred;
  height: 200px;
  width: 200px;
  margin: 30px;
}

dom的寬度,開發(fā)記錄,css,css3,前端

dom的寬度,開發(fā)記錄,css,css3,前端

    <div className="App">
      <div className='state_box'></div>
      <div className='parent_box' id='parent_box'>
          <div className='box' id='box'>
          </div>
      </div>
    </div>
.state_box {
  height: 200px;
  background-color: aquamarine;
}
.parent_box {
  height: 600px;
  width: 600px;
  background-color: olivedrab;
  margin-left: 100px;
  padding: 30px 50px;
}
.box {
  height: 200px;
  width: 200px;
  background-color: palevioletred;
}

dom的寬度,開發(fā)記錄,css,css3,前端
dom的寬度,開發(fā)記錄,css,css3,前端

const boxDom = document.getElementById('box')

console.log('boxDom',boxDom?.getBoundingClientRect());

dom的寬度,開發(fā)記錄,css,css3,前端

box增加padding,border,margin后

.state_box {
  height: 200px;
  background-color: aquamarine;
}
.parent_box {
  height: 600px;
  width: 600px;
  background-color: olivedrab;
  margin-left: 100px;
  padding: 30px 50px;
}
.box {
  height: 200px;
  width: 200px;
  background-color: palevioletred;
  border: 10px solid orange;
  padding: 10px 20px;
  margin: 10px 20px;
}

dom的寬度,開發(fā)記錄,css,css3,前端
dom的寬度,開發(fā)記錄,css,css3,前端

const boxDom = document.getElementById('box')

console.log('boxDom',boxDom?.getBoundingClientRect());
console.log('getClientRects',boxDom?.getClientRects() );

dom的寬度,開發(fā)記錄,css,css3,前端

HTMLElement.clientWidth

只讀屬性 Element.clientWidth 對于內(nèi)聯(lián)元素以及沒有 CSS 樣式的元素為 0;否則,它是元素內(nèi)部的寬度(以像素為單位)。該屬性包括內(nèi)邊距(padding),但不包括邊框(border)、外邊距(margin)和垂直滾動(dòng)條(如果存在)。

該屬性值會(huì)被四舍五入為一個(gè)整數(shù)。如果你需要一個(gè)小數(shù)值,可使用 element.getBoundingClientRect()

dom的寬度,開發(fā)記錄,css,css3,前端

    <div className="App">
      <div className='state_box'></div>
      <div className='parent_box' id='parent_box'>
          <div className='box' id='box'>
          </div>
      </div>
    </div>
.state_box {
  height: 200px;
  background-color: aquamarine;
}
.parent_box {
  height: 600px;
  width: 600px;
  background-color: olivedrab;
  margin-left: 100px;
  padding: 30px 50px;
}
.box {
  height: 200px;
  width: 200px;
  background-color: palevioletred;
  border: 10px solid orange;
  padding: 10px 20px;
  margin: 10px 20px;
}
const boxDom = document.getElementById('box')
console.log('clientWidth',boxDom?.clientWidth);
console.log('clientHeight',boxDom?.clientHeight);

console.log('clientLeft',boxDom?.clientLeft);
console.log('clientTop',boxDom?.clientTop);

dom的寬度,開發(fā)記錄,css,css3,前端

dom的寬度,開發(fā)記錄,css,css3,前端

clientLeft: element左邊框的寬度即border-left
clientTop: element上邊框的寬度即border-top

dom的寬度,開發(fā)記錄,css,css3,前端

修改border測試

.box {
  height: 200px;
  width: 200px;
  background-color: palevioletred;
  border-top: 30px solid orange;
  border-bottom: 30px solid orange;
  border-left: 20px solid orange;
  border-right: 20px solid orange;
  padding: 10px 20px;
  margin: 10px 20px;
}

dom的寬度,開發(fā)記錄,css,css3,前端

dom的寬度,開發(fā)記錄,css,css3,前端

當(dāng)box改為box-sizing: border-box;

.box {
  height: 200px;
  width: 200px;
  background-color: palevioletred;
  border-top: 30px solid orange;
  border-bottom: 30px solid orange;
  border-left: 20px solid orange;
  border-right: 20px solid orange;
  padding: 10px 20px;
  margin: 10px 20px;
  box-sizing: border-box;
}

dom的寬度,開發(fā)記錄,css,css3,前端

dom的寬度,開發(fā)記錄,css,css3,前端

HTMLElement.offsetWidth

HTMLElement.offsetWidth

HTMLElement.offsetWidth 是一個(gè)只讀屬性,返回一個(gè)元素的布局寬度。一個(gè)典型的offsetWidth 是測量包含元素的邊框 (border)、水平線上的內(nèi)邊距 (padding)、豎直方向滾動(dòng)條 (scrollbar)(如果存在的話)、以及 CSS 設(shè)置的寬度 (width) 的值。

查詢:https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLElement/offsetWidth

dom的寬度,開發(fā)記錄,css,css3,前端

const computeItem = (text, last, paddingRight = 10) => {
  let width = 0;
  const span = document.createElement('span');
  span.innerText = text;
  if (!last) {
    // 非最后一個(gè)元素,padding-right設(shè)置10px
    span.style.paddingRight = `${paddingRight}px`;
  }
  span.className = 'getTextWidth';
  document.querySelector('body')?.appendChild(span);
  span.style.display = 'inline-block';
  width = document.querySelector('.getTextWidth')?.offsetWidth;
  // 移除元素
  document.querySelector('.getTextWidth')?.remove();

  console.log('text-width', width);
  return width;
};

HTMLElement.offsetLeft

HTMLElement.offsetLeft 是一個(gè)只讀屬性,返回當(dāng)前元素左上角相對于 HTMLElement.offsetParent 節(jié)點(diǎn)的左邊界偏移的像素值。

HTMLElement.offsetTop

TMLElement.offsetTop 為只讀屬性,它返回當(dāng)前元素相對于其 offsetParent 元素的頂部內(nèi)邊距的距離。

HTMLElement.offsetParent

HTMLElement.offsetParent 是一個(gè)只讀屬性,返回一個(gè)指向最近的(指包含層級(jí)上的最近)包含該元素的定位元素或者最近的 table, td, th, body 元素。當(dāng)元素的 style.display 設(shè)置為 “none” 時(shí),offsetParent 返回 null。

dom的寬度,開發(fā)記錄,css,css3,前端

dom的寬度,開發(fā)記錄,css,css3,前端

dom的寬度,開發(fā)記錄,css,css3,前端

    const dom = document.querySelector('.box');
    console.log('offsetParent', dom?.offsetParent);

    console.log('offsetLeft', dom?.offsetLeft);//offsetLeft 60

offsetdemo

dom的寬度,開發(fā)記錄,css,css3,前端

dom的寬度,開發(fā)記錄,css,css3,前端

dom的寬度,開發(fā)記錄,css,css3,前端

scrollTop

判斷元素是否滾動(dòng)到底

scrollTop是一個(gè)非整數(shù),而scrollHeight和clientHeight是四舍五入的,因此確定滾動(dòng)區(qū)域是否滾動(dòng)到底的唯一方法是查看滾動(dòng)量是否足夠接近某個(gè)閾值:
Math.abs(element.scrollHeight - element.clientHeight - element.scrollTop) < 1

scrollWidth

Element.scrollWidth 這個(gè)只讀屬性是元素內(nèi)容寬度的一種度量,包括由于 overflow 溢出而在屏幕上不可見的內(nèi)容。

scrollWidth值等于元素在不使用水平滾動(dòng)條的情況下適合視口中的所有內(nèi)容所需的最小寬度。寬度的測量方式與clientWidth相同:它包含元素的內(nèi)邊距,但不包括邊框,外邊距或垂直滾動(dòng)條(如果存在)。它還可以包括偽元素的寬度,例如::before或::after。如果元素的內(nèi)容可以適合而不需要水平滾動(dòng)條,則其scrollWidth等于clientWidth

dom的寬度,開發(fā)記錄,css,css3,前端

.state_box {
  height: 200px;
  background-color: aquamarine;
}
.parent_box {
  height: 600px;
  width: 600px;
  background-color: olivedrab;
  margin-left: 100px;
  padding: 30px 50px;
  overflow: auto;
}
.box {
  height: 200px;
  width: 1000px;
  background-color: palevioletred;
  border-top: 30px solid orange;
  border-bottom: 30px solid orange;
  border-left: 20px solid orange;
  border-right: 20px solid orange;
  padding: 10px 20px;
  margin: 10px 20px;
}
    const boxDom = document.getElementById('box')
    console.log('clientWidth',boxDom?.clientWidth);
    console.log('clientHeight',boxDom?.clientHeight);

    console.log('scrollWidth',boxDom?.scrollWidth);
    console.log('scrollHeight',boxDom?.scrollHeight);

    console.log('scrollLeft',boxDom?.scrollLeft);
    console.log('offsetTop',boxDom?.scrollTop);

dom的寬度,開發(fā)記錄,css,css3,前端

父元素會(huì)出現(xiàn)滾動(dòng)條

  useEffect(() => {

    const boxDom = document.getElementById('box')
   
    console.log('clientWidth', boxDom?.clientWidth);
    console.log('clientHeight', boxDom?.clientHeight);

    console.log('scrollWidth', boxDom?.scrollWidth);
    console.log('scrollHeight', boxDom?.scrollHeight);

    console.log('scrollLeft', boxDom?.scrollLeft);
    console.log('offsetTop', boxDom?.scrollTop);

    // 監(jiān)聽滾動(dòng)事件

    window.addEventListener('scroll', (e) => {
      console.log('e',e);
      console.log('------------------');
      
      const boxDom = document.getElementById('parent_box')
   
      console.log('clientWidth', boxDom?.clientWidth);
      console.log('clientHeight', boxDom?.clientHeight);
  
      console.log('scrollWidth', boxDom?.scrollWidth);
      console.log('scrollHeight', boxDom?.scrollHeight);
  
      console.log('scrollLeft', boxDom?.scrollLeft);
      console.log('offsetTop', boxDom?.scrollTop);
      console.log('------------------');

    }, true)
  }, [])

dom的寬度,開發(fā)記錄,css,css3,前端

事件鼠標(biāo)pageX,pageY,clientX,clientY,screenY,screenX

電腦屏幕左上角 screenX:鼠標(biāo)點(diǎn)擊位置相對于電腦屏幕左上角的水平偏移量 screenY:鼠標(biāo)點(diǎn)擊位置相對于電腦屏幕左上角的垂直偏移量

e.screenX

瀏覽器內(nèi)容區(qū)域左上角 clientX:鼠標(biāo)點(diǎn)擊位置相對于瀏覽器可視區(qū)域的水平偏移量(不會(huì)計(jì)算水平滾動(dòng)的距離) clientY:鼠標(biāo)點(diǎn)擊位置相對于瀏覽器可視區(qū)域的垂直偏移量(不會(huì)計(jì)算垂直滾動(dòng)條的距離)

e.clientX
網(wǎng)頁的左上角 pageX:鼠標(biāo)點(diǎn)擊位置相對于網(wǎng)頁左上角的水平偏移量,也就是clientX加上水平滾動(dòng)條的距離 pageY:鼠標(biāo)點(diǎn)擊位置相對于網(wǎng)頁左上角的垂直平偏移量,也就是clientY加上垂直滾動(dòng)條的距離
e.pageX

offsetX:鼠標(biāo)點(diǎn)擊位置相對于觸發(fā)事件對象的水平距離 offsetY:鼠標(biāo)點(diǎn)擊位置相對于觸發(fā)事件對象的垂直距離

e.nativeEvent.offsetX
<div className="box" onClick={(e) => {
  console.log('e', e);
}}
>
  hello
</div>
e.nativeEvent.layerX
e.nativeEvent.layerY

dom的寬度,開發(fā)記錄,css,css3,前端

HTMLElement.outerText

HTMLElement.outerText是一個(gè)非標(biāo)準(zhǔn)的屬性。作為一個(gè)獲得器,它返回與HTMLElement.innerText一致的值。

demo

一個(gè)box,分為左側(cè)和右側(cè)。

  • 左側(cè)標(biāo)簽長度和右側(cè)標(biāo)簽長度總值小于box長度,全部顯示
  • 左側(cè)標(biāo)簽長度+右側(cè)標(biāo)簽長度 大于 box長度
  • 當(dāng)左側(cè)大于總長度一半時(shí),左側(cè)超出長度顯示…
    dom的寬度,開發(fā)記錄,css,css3,前端
 const leftList = ['hello world', 'this is pencil', '大熊貓', '平攤TER', 'this is pencil', '大熊貓', '平攤TER', 'this is pencil', '大熊貓', '平攤TER'];
  const rightList = ['陽光 沙灘', 'this is pencil', '大熊貓'];
  • 當(dāng)右側(cè)大于總長度一半時(shí),右側(cè)超出顯示長度顯示…
    dom的寬度,開發(fā)記錄,css,css3,前端
const leftList = ['hello world', 'this is pencil', '大熊貓', '平攤TER'];
const rightList = ['陽光 沙灘', 'this is pencil', '大熊貓', '平攤TER', '陽光 沙灘', 'this is pencil', '大熊貓', '平攤TER'];
  • 當(dāng)兩者都超出總長度一半時(shí),左側(cè)和右側(cè)分別顯示…

dom的寬度,開發(fā)記錄,css,css3,前端
dom的寬度,開發(fā)記錄,css,css3,前端

const leftList = ['hello world', 'this is pencil', '大熊貓', '平攤TER', 'this is pencil', '大熊貓', '平攤TER'];
const rightList = ['陽光 沙灘', 'this is pencil', '大熊貓', '平攤TER', '陽光 沙灘', 'this is pencil', '大熊貓', '平攤TER'];

計(jì)算一個(gè)dom元素的長度demo

  const leftList = ['hello world', 'this is pencil', '大熊貓', '平攤TER'];
  const rightList = ['陽光 沙灘', 'this is pencil', '大熊貓', '平攤TER', '陽光 沙灘', 'this is pencil', '大熊貓', '平攤TER'];
  const leftRef = useRef(null);
  const rightRef = useRef(null);

  const [leftWidth, setLeftWidth] = useState<number | undefined>(undefined);
  const [rightWidth, setRightWidth] = useState<number | undefined>(undefined);

  useEffect(() => {
    console.log('leftRef', leftRef);
    console.log('leftRef', leftRef?.current?.clientWidth);
    console.log('rightRef', rightRef);
    console.log('rightRef', rightRef?.current?.clientWidth);

    // 20代表右側(cè)margin-right, 59代碼標(biāo)題width
    // eslint-disable-next-line max-len
    const leftBoxWidth = leftList?.reduce((sum, text, i, arr) => sum + computeItem(text, i === arr?.length - 1), 0) + 20 + 58;
    // eslint-disable-next-line max-len
    const rightBoxWidth = rightList?.reduce((sum, text, i, arr) => sum + computeItem(text,  i === arr?.length - 1), 0) + 20 + 58;
    console.log('leftBoxWidth', leftBoxWidth);
    console.log('leftBoxWidth', rightBoxWidth);
    // 給左右盒子設(shè)置 width

    // 當(dāng)兩者之和超出box寬度時(shí),需要設(shè)置width進(jìn)行...隱藏
    if (leftBoxWidth + rightBoxWidth > 800) {
      if (leftBoxWidth >= 400 && rightBoxWidth >= 400) {
        setLeftWidth(400);
        setRightWidth(400);
      }
      if (leftBoxWidth > 400 && rightBoxWidth < 400) {
        setLeftWidth(800 - rightBoxWidth);
        setRightWidth(rightBoxWidth);
      }
      if (leftBoxWidth < 400 && rightBoxWidth > 400) {
        setLeftWidth(leftBoxWidth);

        setRightWidth(800 - leftBoxWidth);
      }
    } else {
      setLeftWidth(undefined);
      setRightWidth(undefined);
    }
  }, []);
<div className="box">
  <div className="left-box" ref={leftRef} style={{ width: leftWidth }}>
    <span className="title">左側(cè)信息</span>
    {
      leftList?.map((v, i) => (
        <span key={i} className="item">{v}</span>
      ))
    }
  </div> 
  <div className="right-box" ref={rightRef}  style={{ width: rightWidth }}>
    <span className="title">右側(cè)信息</span>
    {
      rightList?.map((v, i) => (
        <span className="item" key={i}>{v}</span>
      ))
    }
  </div>
</div>
.box {
  margin-top: 40px;
  width: 800px;
  border: 1px solid #888;
  display: flex;
  .title {
    padding-right: 10px;
  }

  .left-box {
    margin-right: 20px;
    padding-bottom: 10px;
    padding-top: 10px;
    // 超出不換行
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    box-sizing: border-box;
    

    .item {
      margin-right: 10px;
      background-color: #e7e7e7;
      padding-top: 4px;
      padding-bottom: 4px;

      &:last-child {
        margin-right: 0px;
      }
    }
  }

  .right-box {
    box-sizing: border-box;
    padding-bottom: 10px;
    padding-top: 10px;
    margin-right: 20px;
    // 超出不換行
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    .item {
      margin-right: 10px;
      background-color: #e7e7e7;
      padding-top: 4px;
      padding-bottom: 4px;
      &:last-child {
        margin-right: 0px;
      }
    }

  }
}
window.devicePixelRatio  = 1 //屏幕分辨率1920,瀏覽器縮放比例100%
window.devicePixelRatio  = 1.5 //屏幕分辨率1920,瀏覽器縮放比例150%

window.devicePixelRatio由筆記本電腦屏幕的縮放設(shè)置決定的

  • 像素 屏幕中最小的色塊,每個(gè)色塊稱之為一個(gè)像素(Pixel)
  • 分辨率 分辨率=屏幕水平方向的像素點(diǎn)數(shù) * 屏幕垂直方向的像素點(diǎn)數(shù);

window.devicePixelRatio = 顯示設(shè)備CSS像素分辨率 / 顯示設(shè)備物理像素分辨率
?
顯示設(shè)備寬度物理像素值= window.screen.width * window.devicePixelRatio;

react監(jiān)聽scroll事件無效

  useEffect(() => {

    // 監(jiān)聽滾動(dòng)事件
    window.addEventListener('scroll', (e) => {
      console.log('e',e);
    })
  }, [])  ```

解決是addEventListener事件添加第3個(gè)參數(shù)設(shè)置true即可

```js
  useEffect(() => {

    // 監(jiān)聽滾動(dòng)事件
    window.addEventListener('scroll', (e) => {
      console.log('e',e);

    }, true)
  }, [])

?。?!部分
圖源網(wǎng)絡(luò)文章來源地址http://www.zghlxwxcb.cn/news/detail-762115.html

到了這里,關(guān)于筆記:dom元素各種寬度和高度,getBoundingClientRect,clientWidth,clientHeight,offsetWidth,offsetHeight的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 微信小程序通過createSelectorQuery獲取元素 高度,寬度與界面距離

    微信小程序通過createSelectorQuery獲取元素 高度,寬度與界面距離

    小程序官方有提供給我們一個(gè) const query = wx.createSelectorQuery() 函數(shù) 我們可以先編寫這樣一段代碼 wxml 這里 我們定義了 多塊 view 都用 行內(nèi)樣式設(shè)置了它的 高度和寬度 js編寫代碼如下 我們運(yùn)行代碼 并點(diǎn)擊按鈕 點(diǎn)擊查看 這里 我們獲取了所有 類名中包含 textIn 的元素 并輸出 這里

    2024年02月05日
    瀏覽(95)
  • vue3 使用ref 獲取 dom 元素的高度

    vue3 使用ref 獲取 dom 元素的高度

    代碼實(shí)現(xiàn): 輸出結(jié)果: ?

    2024年02月16日
    瀏覽(25)
  • echarts警告:Can‘t get DOM width or height. Please check dom.clientWidth and dom.clientHeight. ........

    echarts警告:Can‘t get DOM width or height. Please check dom.clientWidth and dom.clientHeight. ........

    具體警告:Can\\\'t get DOM width or height. Please check dom.clientWidth and dom.clientHeight. They should not be 0.For example, you may need to call this in the callback of window.onload ?出現(xiàn)問題:切換tabs初始化不同的echarts,顯示不出來 報(bào)錯(cuò)的大致意思就是:不能找到dom節(jié)點(diǎn)的寬高,寬高獲取不了導(dǎo)致繪制不出圖

    2024年02月16日
    瀏覽(12)
  • 微信小程序如何及時(shí)獲取頁面循環(huán)元素的寬度、高度、距離左邊值、函數(shù)自調(diào)、類似遞歸、閃屏、selectAll、exec、globalData、map、scroll-view

    distanceLeft :定義一個(gè)數(shù)組存儲(chǔ)各個(gè)循環(huán)元素距離左邊的值。 isPage :控制頁面顯示與隱藏。 scrollLeft :動(dòng)態(tài)設(shè)置滾動(dòng)距離。 isAactivity :存儲(chǔ) tabBar 對應(yīng) id 值。因?yàn)閺?tabBar 頁面跳轉(zhuǎn)到 tabBar 頁面時(shí)不能在路徑上攜帶參數(shù),所以此參數(shù)存儲(chǔ)在全局變量中。 在微信小程序中使用

    2024年02月13日
    瀏覽(34)
  • Android獲取文本的寬度和高度

    Android獲取文本的寬度和高度

    方法一:先繪制文本所在的矩形區(qū)域,再獲取矩形區(qū)域的寬度 上述方法由于矩形邊框緊貼文字,所有沒有多余的空間。 方法二:通過Paint的 measureText 方法直接測量文本寬度 此方法計(jì)算出的寬度會(huì)加上開始和結(jié)尾的空間,這個(gè)空間就是文字和文字之間的空間,為了美觀而存在

    2024年02月09日
    瀏覽(21)
  • java讀取圖片的大小、高度、寬度

    java讀取圖片一般分為兩種,一種是直接讀取文件地址,一種是從前端傳送過來的

    2024年02月11日
    瀏覽(15)
  • Qt QTableWidget 表格自適應(yīng) 高度和寬度

    1. 在MainWindow中設(shè)置 1.1.?對被嵌入的子窗口進(jìn)行設(shè)置,去除子窗口的一些影響到嵌入的部件。 pTable:指向子窗口堆內(nèi)存的指針 1.2.?設(shè)置子窗口可以跟隨主窗口自適應(yīng)變化寬度。 水平方向:子窗口的自適應(yīng)縮放。也可以直接在設(shè)計(jì)師中完成。 2. 在QTableWidget ui表格的 cpp文件中設(shè)

    2023年04月21日
    瀏覽(24)
  • Android動(dòng)態(tài)調(diào)整View的寬度和高度

    Android動(dòng)態(tài)調(diào)整View的寬度和高度 在Android開發(fā)中,我們經(jīng)常需要根據(jù)不同的需求來動(dòng)態(tài)地設(shè)置View的寬度和高度。這可以通過代碼來實(shí)現(xiàn),而不是在XML布局中靜態(tài)地設(shè)置。 一、動(dòng)態(tài)設(shè)置View的寬度 要?jiǎng)討B(tài)設(shè)置View的寬度,我們可以使用LayoutParams類。LayoutParams是一個(gè)用于描述View的布

    2024年02月07日
    瀏覽(47)
  • vue如何實(shí)現(xiàn)實(shí)時(shí)監(jiān)聽頁面寬度高度變化

    運(yùn)用的主要技術(shù):watch監(jiān)聽 話不多說直接上代碼,自行研究

    2024年02月11日
    瀏覽(26)
  • 如何動(dòng)態(tài)設(shè)置vue組件的寬度和高度?

    如何動(dòng)態(tài)設(shè)置vue組件的寬度和高度?

    在組件最外層加上div 給div加上屬性:style=“{ height: toggleHeight ? toggleHeight : ‘2000px’, width: toggleWidth ? toggleWidth : ‘1188px’ }” 使用js修改toggleHeight 和 toggleWidth 的值 實(shí)現(xiàn)動(dòng)態(tài)修改寬高 例 在父組件中動(dòng)態(tài)修改子組件的寬度 auditInformation子組件中 index父組件中

    2024年02月12日
    瀏覽(22)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包