[英]Wordpress Theme Twenty Seventeen - Header image for 4k display
I'm currently working on a wordpress blog using the standard Twenty Seventeen theme.我目前正在使用标准的 27 岁主题开发一个 wordpress 博客。 When setting a custom header image, the maximum width of the uploaded header image that is shown on any display is 2000px (larger images are resized).
设置自定义标题图片时,上传的标题图片在任何显示器上显示的最大宽度为 2000 像素(较大的图片会调整大小)。 This, however, looks quite ugly on a 4k screen.
然而,这在 4k 屏幕上看起来很丑陋。 Is there a possibility to allow for larger images when the browser width is larger than the 2000 pixels?
当浏览器宽度大于 2000 像素时,是否有可能允许更大的图像? My source image has a size of 6000 x 4000 pixels.
我的源图像的大小为 6000 x 4000 像素。
I appreciate your help.我很感激你的帮助。
You could use jQuery conditions mixed with url and if statements to achieve this you could use $(window) functions like below then you could store the image location to a variable and pass it in is the property value to change the background depending on the screen size eg:您可以使用与 url 和 if 语句混合的 jQuery 条件来实现这一点,您可以使用如下所示的 $(window) 函数,然后您可以将图像位置存储到一个变量中,并将其传递给属性值以根据屏幕更改背景尺寸例如:
var width = $(window).width();
var height = $(window).height();
if ((width >= 1024 ) && (height>=768)) {
$url = 'http://mywebsite.com/files/myfile.jpg'
}
else {
$url = 'http://mywebsite.com/files/default.jpg'
}
Then use the jQuery .css method to change the background image of the body or div you want to change for the screen size eg:然后使用 jQuery .css 方法更改要针对屏幕大小更改的 body 或 div 的背景图像,例如:
$('#myDivId').css('background-image', url);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.