I had put a text beside image. I want to shift that text up but not able to do it. Padding bottom is not working on it. Tried everything but still facing this issue.
Code:
section {
margin-top: 0px;
width: 100%;
overflow: hidden;
background-color: #ffffff;
height: auto;
}
section ul li {
display: inline-block;
}
.left-section {
float: left;
width: 40%;
}
.right-section {
float: right;
width: 58%;
margin-top: -70px;
text-align: right;
height: auto;
}
.pp {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-weight: 700;
color: #3b6cff;
font-size: 38px;
padding: 15px;
margin-bottom: 11px;
}
figure {
display: inline-block;
width: 50px;
height: 50px;
border-radius: 50px;
font-size: 12px;
text-align: center;
margin-right: 10px;
background: #fff;
line-height: 1.7em;
border: 1px solid #ccc;
}
figure img {
display: inline-block;
width: 22px;
height: auto;
margin-bottom: -22px;
}
.sp1 {
/* margin-left: 323px;*/
padding-right: 100%;
}
.pp1 {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
padding-right: 80%;
}
<section>
<ul class="left-section">
<li><img class="prog" src="images/programming.png" alt=""></li>
<li class="pp">DGcom</li>
</ul>
<ul class="right-section">
<li class="sp1">
<figure>
<img src="images/clk.png" alt="">
</figure>
</li>
<li class="pp1">Opening Hour</li>
</ul>
</section>
Pls Refer above code and let me know how to fixed it.
I’m creating section with logo and some details like opening hours, call us, etc. You can see the screenshot.
4
Answers
Personally I would advise changing your HTML. You are using two separate list items to create the icon-text element which doesn’t really make sense. Based on the design, the icon is merely a visual indicator of what the text is telling the user. As such they should be part of the same element i.e. a single
<li>
containing both the icon and the text. Your html should therefore look more like this:To get the icon and the text to line up as you wish,
display: flex
is the solution I – and many others – would suggest. The CSS to achieve this, based on the HTML I’ve provided above would be as follows:Setting the image to
display: block
will make it easier and more predictable to work with. As an aside, personally I would advise setting all<img>
s todisplay: block
in your reset.Setting your
<li>
todisplay: flex
will automatically put the icon and the text side by side. Settingalign-items: center
will then align the icon and the text as you want it to. I have usedgap
to create the space between the icon and the text but usingmargin
would work too.You have to change HTML for your solution. Kindly check my answer.
You can use simply use grid to align items as like as you want
look likes this:
Based on the code you provided, it appears that the text you are trying to move up is the "DGcom" text beside the programming image. To move this text up, you can try adjusting the padding or margin values of the ".pp" class in your CSS code. Here’s an example:
In the example above, I removed the margin-bottom property and set the top and bottom padding to 0, while keeping the left and right padding at 15px. This should move the "DGcom" text up closer to the programming image.
If this doesn’t work, you may need to adjust the margin or padding values of the "ul" and "li" elements surrounding the image and text. You can also try adjusting the "line-height" property of the "pp" class to reduce the space between lines of text.
I hope this helps! Let me know if you have any further questions.