基于Photodeck搭建摄影网站:为菜单及Logo添加背景的CSS/HTML求助
Hey there! I know it's frustrating when a site builder doesn't let you tweak something as basic as a background—let's get this sorted for your photography website. Since you're new to coding, I'll break this down into simple, copy-paste steps using the elements from your code.
Step 1: Target the Navigation Block (Menu + Logo Container)
Looking at your HTML snippet, the navigation area is wrapped in <pd-block id="navib">. We'll use this unique ID to add a background to the entire menu bar first. Add this CSS to your theme's custom styles section:
#navib { background-color: #222222; /* Replace with your desired color—this is a dark gray example */ padding: 10px 20px; /* Adds space inside the background so content isn't squished */ width: 100%; /* Makes the background span the full width of the page */ box-sizing: border-box; /* Ensures padding doesn't make the bar wider than the page */ }
Step 2: Add a Separate Background to the Logo (If Needed)
If you want a distinct background just for the logo (instead of the whole navigation bar), find the element wrapping your logo inside #navib (it might have a class like pd-logo—adjust the selector if your actual class is different). Add this CSS:
#navib .pd-logo { background-color: #ffffff; /* White background for the logo */ padding: 5px 10px; /* Adds space around the logo */ border-radius: 4px; /* Optional: rounds the corners of the logo background */ }
Step 3: Fix Hidden Backgrounds (Troubleshooting)
Sometimes default theme styles can hide your custom background. If it's not showing up, try adding !important temporarily to force the style (this is a quick fix—you can remove it once you confirm it works):
#navib { background-color: #222222 !important; }
Quick Beginner-Friendly Explanation
#navib: Targets your specific navigation block using its unique ID, so styles only apply here.background-color: Sets a solid color background—use hex codes, RGB values, or even simple names likenavyto match your brand.padding: Creates breathing room between the background edge and your menu/logo text, so everything looks polished.width: 100%: Ensures the background stretches across the full width of your site, no awkward gaps.
Just paste these styles into your theme's custom CSS editor, and you should see the background appear immediately!
内容的提问来源于stack exchange,提问作者GGK

