navbar-expand-md fixed-top justify-content-center" style="background: rgba(0,0,0,0.7); color: white;">Promotional bannertext goes here promotional banner text goes here promotional banner text goes here</nav>
如果图像比浏览器的宽度宽,我希望裁剪图像而不是调整它的大小。不应该有水平滚动条。 只有CSS的解决方案是首选的,但PHP是可以接受的,JS不太可取,但仍然很受欢迎。使用背景图像并不理想。 ? browser width and cover photo must retain the center of cropped image 此代码块给出了我尝试过的内容,但可能没有太大帮助: .banner-container{ position: relative;
所以我的实际问题是,我想要一个固定的背景图像效果,同时保持背景图像足够宽来填充一个容器。不幸的是,使用background-attachment:fixed;的CSS方式只会相对于视口定位图像。// Banner scroll function var banner = $('.hero-banner');