Javascript 如何在网页上垂直降低图像

Javascript 如何在网页上垂直降低图像,javascript,html,css,Javascript,Html,Css,我在试图找出如何降低网站上的图像时失败了。 我看到很多人只是简单地做.img{…}并以这种方式编辑它,问题是我有不止一个img正在使用该标记,所以如果我以这种方式编辑它,它将影响所有使用它的标记,这不是我想要的。简单地说,我有一个图像显示在我的网站顶部附近,我只希望它放低一些。对于该类,以下是代码: .bichon{ display: block; margin-left: auto; margin-right: auto; height: 300px; width: 850px;

我在试图找出如何降低网站上的图像时失败了。 我看到很多人只是简单地做.img{…}并以这种方式编辑它,问题是我有不止一个img正在使用该标记,所以如果我以这种方式编辑它,它将影响所有使用它的标记,这不是我想要的。简单地说,我有一个图像显示在我的网站顶部附近,我只希望它放低一些。对于该类,以下是代码:

.bichon{
 display: block;
 margin-left: auto;
 margin-right: auto;
  height: 300px;
  width: 850px;
}
对于我的类,然后对于图像插入:

<img src = "https://upload.wikimedia.org/wikipedia/commons/thumb/9/93/Bichon_Fris%C3%A9_-_studdogbichon.jpg/1200px-Bichon_Fris%C3%A9_-_studdogbichon.jpg" class = "bichon">

图像水平居中,但我只是想将其垂直降低一点,这样它就不会遮住我的导航栏。
谢谢。

你可以在顶部留一个空白。这会降低你的形象。我建议使页边距顶部等于导航栏的高度

.bichon{
  display: block;
  margin-top: 80px; //the height of your navigation bar
  margin-left: auto;
  margin-right: auto;
  height: 300px;
  width: 850px;

}

我猜您需要最高保证金:50px。您可以根据要降低图像的程度更改50px。
.bichon{
  display: block;
  margin-top: 80px; //the height of your navigation bar
  margin-left: auto;
  margin-right: auto;
  height: 300px;
  width: 850px;