【问题标题】:How to remove or change "height" at element.style?如何删除或更改 element.style 的“高度”?
【发布时间】:2016-07-09 00:26:57
【问题描述】:

我正在用 figure&figcaption 标记一些图像页面,这是一种画廊滑块。

但是当我在 Chrome 开发者工具中看到代码时,元素样式图 img、figcaption img 中的高度大小自动相同。

我想我需要更改此代码。

	for( var i = 0; i < wall.itemsCount; ++i ) {

				var $item = wall.$items.eq( i );

				$item.appendTo( $wallElem );

				var itemH = $item.height(),
					figcaptionH = $item.find( 'figcaption' ).outerHeight( true );

				if( itemH > wallH - wallmargins ) {
					$item.find('img').height( wallH - wallmargins - figcaptionH );
					$item.css( 'top', ( wallmargins / 2 ));
				}
				else {
					$item.css( 'top', ( wallH - itemH ) / 2 );
				}
				
				

请给我建议。

【问题讨论】:

    标签: javascript jquery html


    【解决方案1】:

    如果您只想更新 figcaption img 的高度,请更新您的选择器以包含该高度

    $item.find('figcaption img').height(wallH - wallmargins - figcaptionH);
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多