我有一个图像列表
<img src="001.jpg">
<img src="002.jpg">
<img src="003.jpg">
<img src="004.jpg">
<img src="005.jpg">
Run Code Online (Sandbox Code Playgroud)
每张图像的宽度为 200 像素,但高度不同。有没有办法用 Jquery 来查找,然后在加载后设置每个图像的高度?
我计划在一个页面上放置数十张图片,并且不想为每个单独的图片标签添加宽度和高度属性。
我正在使用 Masonry 插件,它需要图像的宽度和高度属性。
我有一个以页面为中心的标题(h1).我想在标题的左侧和右侧添加线条,以便它们填充页面宽度的其余部分.但是,我希望线条适应标题的宽度,这是动态的.所以,我希望动态计算线的宽度.
这是我想要完成的一个例子:http://jsfiddle.net/cAEqE/1/
在示例中,我将线条的宽度设置为35%,以便它们可以获得我想要的效果.但是,如果标题更长,它将分为2行,我不希望这种情况发生.
我的老板告诉我要避免使用javascript,所以只使用CSS会很棒.但是,如果事实证明这是不可能的,我将转向优秀的旧jQuery.干杯!
编辑:网站有背景图片,所以我不能在h1上使用背景.谢谢!
我需要获取WebView的宽度和高度,并将它们传递到要在WebView中加载的URL的查询字符串中。我在onResume()中找到了一种方法。由于此时尚未计算宽度和高度,因此我在UI加载后将Runnable发布到要排队的WebView中。
这是我的问题:当方向更改时,我在onConfigurationChanged中处理它。当我尝试在onConfigurationChanged中将Runnable发布到WebView时,WebView的宽度和高度最终是旧方向的宽度和高度。方向更改后,在什么时候可以截取新的宽度和高度?
android width orientation screen-orientation onconfigurationchanged
我在我的JavaScript代码中附加了一个图像,但想要获得正确的宽度和高度.这可能吗?我的代码看起来像这样:
$('body').append('<img src="path.jpg" width="'
+ w + '" height="' + h + '" alt="" />');
Run Code Online (Sandbox Code Playgroud)
我知道如何在加载后获得图像宽度,但我正在加载img并希望直接获得相应的宽度和高度.有小费吗?
我的页面中有一个iframe.像这样 :
<iframe width="600px">
<html>
<head>
</head>
<body>
<p>Some text</p>
<img src="/foo/bar/test.png" />
</body>
</html>
</iframe>
Run Code Online (Sandbox Code Playgroud)
我希望能够检测iframe内容是否大于600px.我试过这个:
var iframe = $('iframe');
if (iframe.width() < iframe.contents().width()) {
console.log('contents larger than the iframe');
}
Run Code Online (Sandbox Code Playgroud)
它适用于Firefox和Internet Explorer.但不是Chrome.在Chrome上,iframe.contents().width()是600.
我试过iframe.contents().find('body').width()但结果也是600.
如何在Chrome中检测iframe内容的实际宽度?
我创建了一个包含一些测试数据的数据表.我的问题是,对于我的一个列,某些值太大,导致一个奇怪的布局:

(在订单栏之后应显示另外两列)
我已经尝试了一些事情:
<p:column headerText="Orders" width="50"> 没有变化<p:column headerText="Orders" style="max-width: 30px;"> 使列更稀疏,但值在30px后被切断<br/>强制断裂线,但没有变化订单值是一个大字符串.我的目标是将orders列更改为多行列,其中字符串值被拆分.
我的数据表代码:
<h:body>
<h:head>
</h:head>
<h:form id="form">
<p:dataTable id="customerTable" var="customer" value="#{customerDataTable.allCustomer}"
rows="25" paginator="true" emptyMessage="No customer found.">
<p:column headerText="Customer ID" style="text-align: center;">
<h:outputText value="#{customer.customerNumber}" />
</p:column>
<p:column headerText="Fist Name" style="text-align: center;">
<h:outputText value="#{customer.contactFirstName}" />
</p:column>
<p:column headerText="Last Name" style="text-align: center;">
<h:outputText value="#{customer.contactLastName}" />
</p:column>
<p:column headerText="Sales Employee Nr." style="text-align: center;">
<h:outputText value="#{customer.employee.employeeNumber}" />
</p:column>
<p:column headerText="Orders">
<h:outputText value="#{customer.allOrders}"/>
</p:column>
<p:column headerText="Payments" style="text-align: center;" >
<p:commandButton id="payment_btn" …Run Code Online (Sandbox Code Playgroud) 演示小提琴:http://jsfiddle.net/UI_Designer/2gqy9s9k/1/
容器有4个块.每个div包含 width:25%..所以履行容器......
如果我删除任何一个div容器有空的空间..但我想再次履行容器..它可能吗?
.container{
width:100%;
border:1px solid #333
}
.badge-block{
float:left;
width: 25%;
}
.badge-block img{
width:80%;
}
Run Code Online (Sandbox Code Playgroud) <input type="file" class="test" name="vend_logo" id="vend_logo">
$('.test').bind('change', function() {
var file = files[0]
var img = new Image();
var width = img.width;alert(width);
});
Run Code Online (Sandbox Code Playgroud)
我想提醒上传的图片宽度和高度.我怎样才能做到这一点 ?我已经使用过了clientwidth,naturalwidth但它没有显示正确的值.
我想做的事
目前,我的绘图有一个自定义主题,我想在此基础上为所有类型的绘图提供一些预定义的参数。我首先关注的是条形图,我想在其中更改默认宽度。
ggplot2中geom_bar的默认宽度为“ 默认情况下,设置为数据分辨率的90%。 ”(http://ggplot2.tidyverse.org/reference/geom_bar.html)。
我想将默认值更改为75%。需要明确的是,我不希望这样更改它:
geom_bar(stat='identity', width=0.75)
因为那意味着我每次创建条形图时都必须指定它。我希望它是新的默认值。
到目前为止我尝试过的
我尝试使用此方法更改默认宽度:
update_geom_defaults("bar", list(width=0.75))
但随后我收到一条错误消息:Error: Aesthetics must be either length 1 or the same as the data (964): width。我在想这可能是由于宽度是根据数据的分辨率计算出来的,在我打电话的那一刻还没有update_geom_defaults
另外,我还意识到这width不是bar的默认aes的一部分:
GeomBar$default_aes
* colour -> NA
* fill -> "grey35"
* size -> 0.5
* linetype -> 1
* alpha -> NA
Run Code Online (Sandbox Code Playgroud)
我的问题是:
谢谢 !
我有一个带有选项的垫选,我希望将此内联设置为文本,并且下拉列表的长度只能与最长的选项一样长。我可能可以使用js / css香草样式来做一些黑客,但是正在寻找更好的解决方案。有什么想法吗?
<mat-select
[ngClass]="{'missing-selection': !SelectedOption}"
[(value)]="SelectedOption"
id="select"
(selectionChange)="optionChange($event)"
>
<mat-option
*ngFor="let option of data.Options"
[value]="option.Value"
>{{ option.Label}}</mat-option
>
</mat-select>
Run Code Online (Sandbox Code Playgroud)