I am trying to get the text on the right and vertically centered with the image. How can i do this?
My current code is:
<div style="display: table;"> <div style="display: table-cell;"><img src="//dummyimage.com/100"></div> <div style="display: table-cell;">text</div> </div>
use CSS3 Flexible box layout :
from the documentation:
, , . , - , , .
:
#pageElement{display:flex; flex-wrap: nowrap; align-items: center}
<div id="pageElement"> <div> <img src="http://placehold.it/350x150"> </div> <div> text </div> </div>
cheat-sheet ,
vertical-align baseline. middle . MDN.
vertical-align
baseline
middle
.table { display: table; } .table > div { display: table-cell; vertical-align: middle; }
<div class="table"> <div><img src="//dummyimage.com/100"></div> <div>text</div> </div>
Use td, tr and a table.
<body> <table> <tr width="100%;"> <td width="50%;" valign="bottom"> <img style="width:100%" src="https://s.w.org/images/home/screen-themes.png?1"/> </td> <td width="50%;" align="center" valign="center"> text dddddddddddd </td> </tr> </table> </body>
See JsFiddle, for example: https://jsfiddle.net/bndr6x4y/1/
You can set the negative top edge of the text.
<div style="display: table-cell; top-margin: -500px"> text </div>
If the image height was 500 pixels.
Source: https://habr.com/ru/post/1666808/More articles:There is no call function "renameat2" on Ubuntu 16.04 - cAlgorithm complexity: is it the same as iterating an array from the beginning than from the end? - javaWhat is the use of variable declarations only - javascriptBash parsing and shell extension - linuxAlgorithm for combining multiple sorted sequences into one sorted sequence in javascript - javascriptTerritorial remote state - amazon-web-servicesDoes dotenv-webpack provide all environment variables from .env to front-end? - javascriptWhere does the hyperlester fabric store the database for the block chain? - hyperledgerPandas Sort DataFrame ignoring case - pythonhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1666813/is-it-possible-to-use-selenium-webdriver-for-automating-desktop-applications&usg=ALkJrhj9PSPmugFC3rapfWgliKNrYl-4YgAll Articles