Html 如何在html页面中将img src向下移动几个像素

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24923919/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 02:19:59  来源:igfitidea点击:

How to move img src a few pixels down in html page

htmlcss

提问by user3816931

I found a way to make my own custom file upload control , by placing a fake control over it, and when i click the fake one , i am actually cliking the real control below.

我找到了一种方法来制作我自己的自定义文件上传控件,通过在它上面放置一个假控件,当我点击假控件时,我实际上是在点击下面的真实控件。

Anyways the image for the browse button is a little to the top.

无论如何,浏览按钮的图像有点顶部。

How can i lower it down a little?

我怎样才能降低一点?

Here is the js fiddle.

这是js小提琴。

JsFiddle

提琴手

Here is the html and css:

这是html和css:

    <div>
    <div class="fileinputs">
        <input type="file" class="file" />
        <div class="fakefile">
            <input />
            <img src="search.jpg" />
        </div>
    </div>
</div>

div.fileinputs {
position: relative;
}
div.fakefile {
position: absolute;
top: 0px;
left: 0px;
z-index: 1;
}
input.file {
position: relative;
text-align: right;
-moz-opacity:0;
filter:alpha(opacity: 0);
opacity: 0;
z-index: 2;
}

回答by Bijan

I believe this is what you are looking for. jsFiddle

我相信这就是你正在寻找的。js小提琴

CSS

CSS

.moveimage
{
    position: relative;
    top: 3px;
}

Modified HTML

修改后的 HTML

<img class="moveimage" src="search.jpg" />