I'm writing a website and I encountered one problem. I used 'background-image' in CSS, but instead of my image I see grey square. It's Q&A section. Here is the HTML structure and CSS code (I replaced my website content with with other words, the code is the same):
.qa-background {
width: 900px;
background-color: white;
border-radius: 10px;
box-shadow: 2px 3px 5px 0 grey;
vertical-align: middle;
text-align: center;
z-index: 0;
padding: 40px 0 20px 0;
}
.question {
padding: 0;
background-color: white;
border-radius: 10px;
border: 2px solid #169149;
display: flex;
text-align: left;
justify-content: space-between;
padding: 5px 30px 5px 30px;
margin: 0 60px 10px 60px;
z-index: 1;
}
.question p {
color: black;
font-size: 20px;
}
.qa-arrow {
all: unset;
width: 30px;
height: 30px;
margin: 0;
background-image: url('assets/img/icons/qa-arrow.png');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
border: none;
cursor: pointer;
z-index: 2;
}
.qa-arrow:hover {
filter: brightness(1.3);
}
.qa-arrow:active {
transform: scale(0.95);
}
.answer {
background-color: white;
border-radius: 10px;
border: 1px solid #bababa;
text-align: left;
padding: 5px 80px 5px 30px;
display: block;
margin: 0 60px 30px 60px;
z-index: 1;
animation: fadeIn 0.3s ease-in-out;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
<div class="qa-background">
<div class="question">
<p><b>Some really nice question</b></p>
<button class="qa-arrow"></button>
</div>
<div class="answer">
<p>Answer</p>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
</ul>
</div>
<div class="question">
<p><b>Another amazing question</b></p>
<button class="qa-arrow"></button>
</div>
<div class="answer">
<p>Answer<br> some content</p>
</div>
</div>
I have checked file path in HTML and it's correct. I have also checked linking from my HTML file to CSS file and it's also correct. When I style other elements in the document everything works perfectly fine, except this one. I have tried 'all: unset;' option, but now the button is not showing at all, only the cursor is showing. Can someone help me figure out what's wrong, please? :)
assets/...
to/assets/...
../img/icons/qa-arrow.png
and now it works. Before it was showing in the network tab asassets/css/assets/img/icons/qa-arrow.png
. I don't know why it was this way, but now everything works so I'm happy. :) The/assets/img/icons/qa-arrow.png
didn't work unfortunately. I didn't know that browser can read the file path different. Thank you!<base
>` element and please next time focus your code on the question, so nothing more than the<button>
element<base>
applies to URLs in stylesheets.