我有一個通過 CSS 設計的帶有背景圖片的主頁。但是,當頁面加載左側的一部分而右側的一部分保持白色時。我想讓它適合屏幕。這是我的HTML:<header> <section class="bg"> <div [style.color]="'white'"> <h1> Welcome to Shopping Cart</h1> <h2> Online grocery purchase made easy.</h2> </div> </section></header>這是我的CSS.bg{background-image: url('/assets/images/shopping-1.jpg');height: 100vh;background-position: center;background-repeat: no-repeat;background-size: cover;background-attachment: fixed; /*background-size: contain;*//*background-color: darkblue;*/}我試過使用width:100vw但它不起作用。右邊變得更加拉伸,左邊仍然是空白的白色部分。設置width: 84vw;使其在右側正確。但左側仍然是空白。我無法將背景圖像向左移動。如何使整個背景圖像適合屏幕。主頁圖片:
CSS Html Angular 中的主頁背景圖像大小問題
HUH函數
2023-03-24 14:00:49