ผมพบว่า (บางส่วน) ของโค้ด CSS wp-content/themes/twentyseventeen/style.css
ที่ควบคุมความสูงใน
มีรหัสที่ใช้เมื่อไม่เห็นแถบผู้ดูแลระบบ(ผู้ใช้ทั่วไปที่ไม่ระบุชื่อ) ในปัจจุบันที่บรรทัด 3629
.twentyseventeen-front-page.has-header-image .custom-header-media,
.twentyseventeen-front-page.has-header-video .custom-header-media,
.home.blog.has-header-image .custom-header-media,
.home.blog.has-header-video .custom-header-media {
height: 1200px;
height: 100vh;
max-height: 100%;
overflow: hidden;
}
และรหัสที่ใช้เมื่อแถบผู้ดูแลระบบคือมองเห็นได้ (เช่นคุณเข้าสู่ระบบ) ขณะที่เส้น 3646
.admin-bar.twentyseventeen-front-page.has-header-image .custom-header-media,
.admin-bar.twentyseventeen-front-page.has-header-video .custom-header-media,
.admin-bar.home.blog.has-header-image .custom-header-media,
.admin-bar.home.blog.has-header-video .custom-header-media {
height: calc(100vh - 32px);
}
จากนั้นโค้ดที่ใช้กับมือถือในปัจจุบันที่บรรทัดที่ 1638:
.has-header-image.twentyseventeen-front-page .custom-header,
.has-header-video.twentyseventeen-front-page .custom-header,
.has-header-image.home.blog .custom-header,
.has-header-video.home.blog .custom-header {
display: table;
height: 300px;
height: 75vh;
width: 100%;
}
โดยการคัดลอกสามส่วนของ css ลงใน style.css ชุดรูปแบบลูกของฉันและปรับเปลี่ยนheight
คุณลักษณะที่ฉันสามารถปรับความสูงสำหรับภาพส่วนหัวในหน้าแรก ผมตั้งความสูง30vh
, calc(30vh - 32px)
และ30vh
ตามลำดับในแต่ละส่วน ฉันทิ้งคนแรกไว้height: 1200px
คนเดียว
หมายเหตุองค์ประกอบความสูงมีการตั้งค่า100vh
ซึ่งขนาดความสูงเทียบกับความสูงวิวพอร์ต ดังนั้น 100vh คือ 100% ของวิวพอร์ตในขณะที่ 50vh คือ 50% ของวิวพอร์ต
สิ่งหนึ่งที่แปลกคือในหน้าแรกการซูมและตำแหน่งของภาพส่วนหัวจะแตกต่างจากในหน้าอื่น ๆ
ไม่แน่ใจว่านี่เป็นวิธีที่ดีที่สุดหรือไม่ ฉันเปิดให้ตัวเลือกที่ดีกว่า แต่จนถึงขณะนี้มันทำงานในระดับพื้นฐาน
theme-twenty-seventeen
แท็กเมื่อดูเหมือนว่ามีแท็กที่เกี่ยวข้องสำหรับปีก่อนหน้า