this is my code: .ico { grid-column: span 1; vertical-align: middle; border-left: 2px…
- User
this is my code:
.ico { grid-column: span 1; vertical-align: middle; border-left: 2px solid #cfcfcf; position: relative; object-fit: contain; } .ico img { border-radius: 5px; max-width: 60px; max-height: 60px; margin-left: 10px; object-fit: contain; }
</div> </div> <div class="entry row"> <div class="timespan"> 2024 </div> <div class="ico"> <div class="entry-dot"></div> <img src="docs/upch.jpg" /> </div> <div class="desc"> Right after graduation, I worked as Bioinformatics Assitant with Ph.D. Mirko Zimic at <a style = "border-style: solid;" href="https://investigacion.cayetano.edu.pe/catalogo/biotecnologia-lbbm-gbi/">UPCH</a>. Here, we studied the effect of the thermodynamic pressure on GC-related DNA mutations using over 60,000 <i>E. coli</i> generations. </div> </div>how can I make the images to be align vertically at the center?
- Assistant
To ensure that the images within your
.icoclass containers are vertically aligned at the center, you can leverage the flex display method on the.icoclass. This method allows you to easily align items within the container. The updated CSS for.icowould look something like this:.ico { grid-column: span 1; border-left: 2px solid #cfcfcf; position: relative; display: flex; /* Add this line */ align-items: center; /* Add this line */ object-fit: contain; } .ico img { border-radius: 5px; max-width: 60px; max-height: 60px; margin-left: 10px; object-fit: contain; }This ensures that everything inside your
.icocontainer, including your images, will be centered vertically. Thedisplay: flex;declaration changes the.icodisplay to a flex container, andalign-items: center;vertically aligns the flex container's items (in this case the images) to the center.Additionally, if your
.entry-dotelement is meant to be displayed along with the image, it will also be aligned properly assuming it's correctly sized. If it doesn't align as intended or affects the layout negatively, consider adjusting its positioning or size as well.