What I am trying is, "Your Privacy", Description and buttons should be aligned in same line.
HTML:
<div class="cookie-notice">
<div class="cn-body">
<h2 id="title">Your Privacy</h2>
<p id="id-cookie-notice"><span><span>We use cookies to improve your experience on our site.</span></span></p>
<div class="cn-ok">
<a href="#" class="cm-link cn-learn-more">Decline</a>
<div class="cn-buttons"><button type="button" class="cm-btn cm-btn-danger cn-decline">Decline</button><button type="button" class="cm-btn cm-btn-success">Accept</button></div>
</div>
</div>
</div>
CSS:
.cn-body {
display: flex;
flex-direction: column;
font-family: myriad-pro, sans-serif;
gap: 0;
padding: 0;
width: 100%;
padding: 40px 113px;
boder: 1px solid red;
margin: 10px;
}
.cm-btn-danger {
display: none;
}
.cn-ok {
align-items: center;
display: flex;
flex-direction: row-reverse;
gap: 10px;
justify-content: end;
margin-top: 20px
}
Here is the codeply: code
NOTE: Can’t change the HTML code as it is coming from the third party package
2
Answers
We can use
justify-content: start
to align the buttons!I made the middle element
position: absolute
and aligned the element based on the parent, I made the CSS as max responsive as possible, do validate it once before implementation!In this case I would wrap the title and description into another element in order to split the layout into what you want on the left and what you want on the right side.
The
justify-content: space-between
would place your wrappers one on the left and one on the right.For the right section you will need
flex-direction: column
to achieve that output.