简体   繁体   English

无法在HTML中添加徽标

[英]not able to add logo in html

i am editing an html template, the logo dimensions of the template is lower than my logo, i added my logo to the template but its not displaying, 我正在编辑html模板,模板的徽标尺寸小于我的徽标,我将徽标添加到了模板,但未显示,

 @media (max-width: 673px) { #logo { margin-left: 20px; } } #header #logo h1 { font-size: 34px; margin: 0; padding: 0; line-height: 1; font-weight: 700; letter-spacing: 3px; } #header #logo h1 a, #header #logo h1 a:hover { color: #fff; padding-left: 10px; border-left: 4px solid #7c32ff; } #header #logo img { padding: 0; margin: 0; } @media (max-width: 768px) { #header #logo h1 { font-size: 28px; } #header #logo img { max-height: 40px; } } 
 <section class="header-top"> <div class="container box_1170"> <div class="row align-items-center justify-content-between"> <div class="col-lg-6 col-md-6 col-sm-6"> <a href="index.html" class="logo"> <img src="img/long_logo.png" alt=""> </a> </div> <div class="col-lg-6 col-md-6 col-sm-6 search-trigger"> <a href="#" class="search"> <i class="lnr lnr-magnifier" id="search"></i></a> </a> </div> </div> </div> </section> 

my logo dimesnions are 500px*280 i just want to add my logo somehow, is there any way.how can i fix it? 我的徽标尺寸为500px * 280,我只想以某种方式添加徽标,有什么办法。我该如何解决?

In your CSS styles, you are using id selector, but the HTML template has more of classes. 在CSS样式中,您使用的是id选择器,但是HTML模板具有更多的类。

Also make sure the picture you want to include in the template is within the img/ folder 还要确保要包含在模板中的img/img/文件夹中

You're using classes and calling IDs on your .css 您正在使用类并在.css上调用ID

Did you try creating a <div> with a class and adding your logo inside the div ? 您是否尝试使用类创建<div>并将徽标添加到div中? This way you could manipulate the div dimensions and the logo itself until it fits. 这样,您可以操纵div尺寸和徽标本身,直到适合为止。

A simple example :. 一个简单的例子:

CSS : CSS:

.logo {
    background-image: url("img/long_logo.png");
    background-repeat: no-repeat;
    width: 100px;
    height: 100px;
}

BODY : 身体 :

<section class="header-top">
    <div class="container box_1170">
        <div class="row align-items-center justify-content-between">
            <div class="col-lg-6 col-md-6 col-sm-6">
                <a href="index.html">
                        <div class="logo"></div>
                </a>
            </div>
            <div class="col-lg-6 col-md-6 col-sm-6 search-trigger">
                <a href="#" class="search">
                        <i class="lnr lnr-magnifier" id="search"></i></a>
                </a>
            </div>
        </div>
    </div>
</section>

You are using the wrong CSS Selectors. 您使用了错误的CSS选择器。

For example, if you have assigned a class to your HTML elements like as follows: 例如,如果您为HTML元素分配了一个类,如下所示:

<div class="header">
</div>

You should be using "." 您应该使用“。” to apply CSS to it as follows: 将CSS应用于它,如下所示:

.header {}

Whereas "#" is used to select HTML elements with corresponding ID like so: 而“#”用于选择具有相应ID的HTML元素,如下所示:

HTML: HTML:

<div id="header">
</div>

CSS: CSS:

#header{}

Tip - a HTML element can have multiple classes but only one ID. 提示-HTML元素可以具有多个类,但只能有一个ID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM