I am dealing with a situation where I have an
<h2 class="landing-panel-title>
containing a <span class="landing-panel-icon-right ion-ios-search-strong>
. The second class on the span is from an icon font called ionicons. Despite this, it may not be important in this context.
This setup consists of a header and an accompanying icon. My goal is to create a margin between the icon and the title that adjusts itself dynamically (I want the icon all the way to the right when it follows text, and the text all the way to the right when the icon is placed left of the text). I attempted to use text-align
for this purpose, but so far, I haven't been successful.
HTML:
<div class="landing-panel">
<h2 class="landing-panel-title">Site Reviews<span class="landing-panel-icon-right ion-ios-search-strong"></span></h2>
<p class="landing-panel-text">I've been exploring various PTC sites, gathering information, conducting tests, and compiling useful and relevant findings.</p>
</div>
<div class="landing-panel">
<h2 class="landing-panel-title"><span class="landing-panel-icon-left ion-erlenmeyer-flask"></span>Methodical Approach</h2>
<p class="landing-panel-text">We've collected data, tested relevant information alongside my partner, and he's leveraging our guides and knowledge to advance his career in PTCs.</p>
</div>
<div class="landing-panel">
<h2 class="landing-panel-title">Results<span class="landing-panel-icon-right ion-clipboard"></span></h2>
<p class="landing-panel-text">We don't peddle nonsense, we provide credible information deemed authentic and effective by our team. Enjoy the content!</p>
</div>
CSS:
.landing-panel {
background-color: #d5f5e3;
padding: 0.5em;
margin-bottom: 0.5em;
}
.landing-panel-title {
width: 100%;
}
.landing-panel-icon-right, .landing-panel-icon-left {
color: #913D88;
font-size: 3em;
}
.landing-panel-icon-right {
text-align: right;
}
.landing-panel-icon-left {
text-align: left;
}
.landing-panel-title, .landing-panel-icon, .landing-panel-text {
margin: 0;
padding: 0;
}
Any assistance provided will be highly valued.