简体   繁体   English

HTML / CSS div,文本居中且可悬停img

[英]HTML/CSS div with text centered and resisable hover img

so a friend and i are trying to put text hover an image and center it. 所以我和一个朋友正试图将文字悬停在图片上并居中。 we are using bootstrap so we have a div that is responsive and the image is too, so if i resize the page the image will be smaller but will be not centerer and not resized 我们正在使用引导程序,所以我们有一个div可以响应并且图像也是如此,因此,如果我调整页面大小,图像将变小,但不会居中且不会调整大小

so how can we make this right, resizable and centered horizontaly and verticaly?? 那么我们如何才能使此正确,可调整大小并居中水平和垂直居中?

http://s18.postimg.org/bw3itqktx/Captura_de_ecra_2014_03_30_a_s_19_42_22.png http://s18.postimg.org/gth3eumt1/Captura_de_ecra_2014_03_30_a_s_19_42_13.png http://s18.postimg.org/bw3itqktx/Captura_de_ecra_2014_03_30_a_s_19_42_22.png http://s18.postimg.org/gth3eumt1/Captura_de_ecra_2014_03_30_30_a_s_19_42_13.png

This is not a needed bootstrap solution, just a javascript solution. 这不是必需的引导程序解决方案,而只是一个javascript解决方案。 If we know the screen widths and heights by using window.innerHeight and window.innerWidth, we can just use window.onresize function () { Write what is need to place circle where you wanted based of inner width and inner height} Post a jsfiddle as Rob suggested and i will write you the needed javascript. 如果我们通过使用window.innerHeight和window.innerWidth知道屏幕的宽度和高度,则可以只使用window.onresize函数(){根据内部宽度和内部高度写出所需的圆放置位置}发表jsfiddle正如罗伯建议的那样,我将为您编写所需的JavaScript。 It hard to do without having tags present. 没有标签就很难做到。 you can use document.getElementById and document.getElementByClassName to get the elements. 您可以使用document.getElementById和document.getElementByClassName来获取元素。 and adjust them with style attributes. 并使用样式属性对其进行调整。 Good Luck! 祝好运! let me know if this helps. 让我知道这是否有帮助。 -Drew -画

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

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