为什么当我使用background:url()时我的图像从不显示?

时间:2019-05-19 15:26:11

标签: css background

我花了很长时间尝试找出为什么我的代码未正确执行后台:url()。我的图像“ beardlawyer.jpg”与我的html和css文件位于同一文件夹中。

我已经尝试过的事情:

background: url("/Best Lawyer Website/beardlawyer.jpg");

background: url('beardlawyer.jpg');

background: url(/beardlawyer.jpg);

background: url('/beardlawyer.jpg);

老实说,我不明白人们为什么在括号内使用'标记或'。

实际html

<section id="showcase">
        <div class="container">
            <h1> Experienced lawyers at a moments notice </h1>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
        </div>
    </section>

目前的CSS

#showcase {
    min-height: 200px;
    background:url("/Best Lawyer Website/beardlawyer.jpg");
}

1 个答案:

答案 0 :(得分:1)

使用background-image并在元素上指定宽度和高度。

float
def check_age(age):
    #age = int(age)                          - removed this one, should happen at input
    return 30 * 6 if age >= 30 else 0

def just_married():
    sum_married = 0
    woman_age = int(input("Please enter the wife age [we know that is not ok ask woman about she's age] : ").strip())
    sum_married = sum_married + check_age(woman_age)
    husband = int(input("Please enter the husband age : ").strip())
    sum_married = sum_married + check_age(husband)
    return sum_married                       # removed int(), it is already an integer

def children_age(number_of_children):
    sum_children = number_of_children*50
    return sum_children                      # removed int(), it was too late here
                                             # and it should happen at input


def work_hard():
    print("for WIFE - Are you working part-time (0.5) or full-time (1)? : ")
    wife_work = float(input())               # added float()
    print("for HUSBAND = Are you working part-time (0.5) or full-time (1)? : ")
    husband_work = float(input())            # added float()
    sum_work = (wife_work+husband_work)*75
    return int(sum_work)                     # int() may stay, depending on what should happen
                                             # with fractions - they are just thrown away now

def main():
    sum_func = 0
    print("The following is a program aimed at examining eligibility conditions "
          "for participation in the tender Housing for the occupant.")
    sum_func += just_married()
    print("How many children over the age of 18 do you have? : ")
    children = int(input())                  # added int()
    sum_func += children_age(children)
    sum_func += work_hard()
    program_number = 599
    if sum_func > program_number:
        print("you got : " + str(sum_func) + " points ")
    else:
        print("sorry, but you need " + str(program_number-sum_func) + " point to join the program. try next time.")

main()