简体   繁体   English

Wordpress 主题二十七 - 4k 显示的标题图像

[英]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.

相关问题 WordPress的二十七个自定义标题样式标签 - Wordpress twenty seventeen custom header style tag 将新的文本框添加到Wordpress二十七标题 - Add New Text Box To Wordpress Twenty Seventeen Header 如何在 Wordpress 二十七中为我的 header 使用 iFrame? - How do I use an iFrame for my header in Wordpress twenty seventeen? 如何更改二十七主题的默认“帖子”标题? - How to change the default "Posts" title of the twenty seventeen theme? WordPress二十十三儿童主题更改标题横幅大小 - WordPress Twenty Thirteen Child Theme Change Header Banner size WordPress显示完整博客文章标题(二十二个主题十二) - Wordpress display Full Blog post Title (Twenty Twelve Theme) 在Wordpress 22主题摘录中更改标题和特色图片的顺序 - Change the order of title and featured image in Wordpress twenty twelve theme excerpt ACF 字段未显示在 index.php 生成的二十七主题页面上 - ACF field not displaying on index.php generated pages in Twenty Seventeen theme WordPress 二十七静态主页不执行我的自定义模板 - WordPress Twenty Seventeen static home page doesn't execute my custom template 自定义 WordPress 主题(二十十三)。 如何从标题中删除一个标题而不将其全部删除 - Customizing WordPress theme (Twenty Thirteen). How to remove one title from the header without removing them all
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM