Solution 1 :

i think you should add <div class="image-conatiner"></div> to have more control on images in your model don’t leave them without any element to control them. check the code below

.Card_Badge {
  box-sizing: border-box;
  max-height: 350px;
  overflow: hidden;
}
.image-container{
display:flex;
}
<div class="Card_Badge">
 <div class="image-container">
  <img alt="Badge Background" src="https://via.placeholder.com/100" style="max-width: 100px;max-height: 146px;display: flex;z-index: 1;">
  <img alt="Secured Card" src="https://via.placeholder.com/100" ">
  </div>
</div>

Solution 2 :

here this should work fine, use the gap property to set how far apart you want the elements to be.

    .Card_Badge {
    box-sizing: border-box;
    max-height: 350px;
    overflow: hidden;
  display: flex;
  flex-flow: row nowrap;
  gap: 5em;
}

Problem :

I was tasked with building a relatively simple module for a new client test experience, but I feel like I can optimize the code. Important: I do not have access to the client’s site, I am just supposed to build this module using HTML and CSS manipulation.

Currently, the relevant page contains a card image with some text underneath. I must introduce a new image of a badge which is meant to sit right to the left of the card. Here’s what it is meant to look like:

enter image description here

This is the code block I currently have set up for that particular configuration:

.Card_Badge {
  box-sizing: border-box;
  max-height: 350px;
  overflow: hidden;
}
<div class="Card_Badge">
  <img alt="Badge Background" src="https://via.placeholder.com/100" style="max-width: 100px;max-height: 146px;display: flex;z-index: 1;">
  <img alt="Secured Card" src="https://via.placeholder.com/100" style="transform: translate(65px,-150px);">
</div>

Without the transform: translate() the images simple stack onto one another. There has to be a better way to accomplish the desired effect of the images being right next to one another without manipulating the positioning so excessively, right? Maybe with some kind of position: or display: component, but I admit that I am still not incredibly well-versed with how those work.

Any help would be greatly appreciated.

UPDATE: Here is the adjusted code that I have. The only issue I’m still having is that the shadow underneath the card element gets clipped to the right of one of the <div> containers. Not sure how to get around that.

`

`

Comments

Comment posted by isherwood

Your CSS can’t work because the selector lacks a dot. Please fix the demo above to show the problem. Also, inline styles are a pain for all involved.

Comment posted by Align

elements side by side

Does this answer your question?

Comment posted by Glen tea.

if you don’t specify the nowrap property, they’ll still stack if the screen get small enough.

Comment posted by bwoin

Thanks! So I tried a version of this that seems to help, but the main issue that I’m running into now is my topmost

container only being so large (640px apparently). There is a shadow on the card element and that is getting cut off at the right side when I use this configuration. Is there a way to expand past this container and show the full image without manipulating the badge element or anything?

Comment posted by Abdel Rahman Yosry

can you send the code? anyway div card have no by default width:auto; that mean it will fit for the image automatically you can add width: max-content;

Comment posted by bwoin

@AbdelRahmanYosry – Hey, yes I can. I just added it an Update to the end of my original post.

Comment posted by Abdel Rahman Yosry

That’s good keep going bro 🙂 — up vote pls

Comment posted by Glen tea.

hm, I got minus. well thats… fun. And I was still building a better answer to explain further, yall couldn’t give me like a minute to explain it better lol.

By