I am not good with CSS. I am having an issue to place my Icon on the Right Side and In the middle. I tried my best as per my knowledge but couldn't succeed. Please Help.
[Example Image][1] [https://i.stack.imgur.com/H49kU.png][1]
The Red Circled fontawesome's icon that you can see is next to the text. I want to place it on Blue Cross (x).
I have placed all my coding in snippets. Please check and identify the error and help me to fix it.
<script src="https://kit.fontawesome.com/69abb77bd4.js" crossorigin="anonymous"></script>
.mock_exams_title {
font-weight: 400;
font-family: "avenir-medium", Verdana, Arial, Sans-Serif;
line-height: 3rem;
font-size: 1.8rem;
letter-spacing: normal;
background-color: #f2f2f2;
color: #000;
padding: 5px 10px;
text-align: center;
margin-bottom: 30px;
}
.mock_panel {
margin-left: 5px;
display: flex;
flex-wrap: wrap;
}
.pdf_stamp_name {
color: red;
}
.mock_name {
min-height: 50px;
}
.mock_name_text {
font-size: 1.5em;
color: #000;
}
.mock_link {
width: calc(100% / 2);
box-sizing: border-box;
padding: 0 10px;
margin: 0 0 30px;
border-bottom: 1px solid #000;
}
.mock_exams_container {
width: 70%;
margin: 0 auto;
}
@media only screen and (max-width: 700px) {
.mock_exams_container {
width: unset;
}
}
.mock_pdf_icon {
font-size: 20px;
margin-left: 5px;
color: #000;
}
<div class="mock_exams">
<h3 class="mock_exams_heading">Download AB Mock Exams</h3>
</div>
<div class="mock_exams_container">
<h4 class="mock_exams_title">MOCK EXAMS</h4>
<div class="mock_panel">
<a class="mock_link" href="#" target="_blank">
<p class="pdf_stamp"><span class="pdf_stamp_name">PDF</span></p>
<div class="mock">
<p class="mock_name"><span class="mock_name_text">Mock AB Mock AB Mock AB Mock AB Mock AB Mock AB Mock AB Mock AB Mock AB </span><span class="mock_pdf_icon"><i class="fas fa-download"></i></span></p>
</div>
</a>
<a class="mock_link" href="#" target="_blank">
<p class="pdf_stamp"><span class="pdf_stamp_name">PDF</span></p>
<div class="mock">
<p class="mock_name"><span class="mock_name_text">Mock AB</span><span class="mock_pdf_icon"><i class="fas fa-download"></i></span></p>
</div>
</a>
</div>
</div>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
CodePudding user response:
You can simply add another i class
w/ the icon and give it a class to set absolute positioning. Please click full-page when viewing the snippet. To make these icons responsive I encourage using media queries
.mock_exams_title {
font-weight: 400;
font-family: "avenir-medium", Verdana, Arial, Sans-Serif;
line-height: 3rem;
font-size: 1.8rem;
letter-spacing: normal;
background-color: #f2f2f2;
color: #000;
padding: 5px 10px;
text-align: center;
margin-bottom: 30px;
}
.mock_panel {
margin-left: 5px;
display: flex;
flex-wrap: wrap;
}
.pdf_stamp_name {
color: red;
}
.mock_name {
min-height: 50px;
}
.mock_name_text {
font-size: 1.5em;
color: #000;
}
.mock_link {
width: calc(100% / 2);
box-sizing: border-box;
padding: 0 10px;
margin: 0 0 30px;
border-bottom: 1px solid #000;
}
.mock_exams_container {
width: 70%;
margin: 0 auto;
}
@media only screen and (max-width: 700px) {
.mock_exams_container {
width: unset;
}
}
.mock_pdf_icon {
font-size: 20px;
margin-left: 5px;
color: #000;
}
.right {
position: absolute;
top: 11.5vw;
left: 48vw;
}
.mock1 .pdf_stamp_name {
margin-left: 1rem;
}
.bottom {
position: absolute;
left: 50.5vw;
top: 26vh;
}
<script src="https://kit.fontawesome.com/69abb77bd4.js" crossorigin="anonymous"></script>
<div class="mock_exams">
<h3 class="mock_exams_heading">Download AB Mock Exams</h3>
</div>
<div class="mock_exams_container">
<h4 class="mock_exams_title">MOCK EXAMS</h4>
<div class="mock_panel">
<a class="mock_link" href="#" target="_blank">
<p class="pdf_stamp"><span class="pdf_stamp_name">PDF</span></p>
<div class="mock">
<p class="mock_name"><span class="mock_name_text">Mock AB Mock AB Mock AB Mock AB Mock AB Mock AB Mock AB Mock AB Mock AB </span><span class="mock_pdf_icon"><i class="fas fa-download"></i><i class="fas fa-download right"></i></span></p>
</div>
</a>
<a class="mock_link" href="#" target="_blank">
<p class="pdf_stamp"><span class="pdf_stamp_name">PDF</span></p>
<div class="mock1">
<p class="mock_name"><span class="mock_name_text">Mock AB</span><span class="mock_pdf_icon"><i class="fas fa-download"></i><i class="fas fa-download bottom"></i></span></p>
</div>
</a>
</div>
</div>
<iframe name="sif2" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
CodePudding user response:
Try using flex:
.mock_name {
display: flex;
align-items: center;
justify-content: center;
}
.mock_exams_title {
font-weight: 400;
font-family: "avenir-medium", Verdana, Arial, Sans-Serif;
line-height: 3rem;
font-size: 1.8rem;
letter-spacing: normal;
background-color: #f2f2f2;
color: #000;
padding: 5px 10px;
text-align: center;
margin-bottom: 30px;
}
.mock_panel {
margin-left: 5px;
display: flex;
flex-wrap: wrap;
}
.pdf_stamp_name {
color: red;
}
.mock_name {
min-height: 50px;
display: flex;
align-items: center;
justify-content: center;
}
.mock_name_text {
font-size: 1.5em;
color: #000;
}
.mock_link {
width: calc(100% / 2);
box-sizing: border-box;
padding: 0 10px;
margin: 0 0 30px;
border-bottom: 1px solid #000;
}
.mock_exams_container {
width: 70%;
margin: 0 auto;
}
@media only screen and (max-width: 700px) {
.mock_exams_container {
width: unset;
}
}
.mock_pdf_icon {
font-size: 20px;
margin-left: 5px;
color: #000;
}
<script src="https://kit.fontawesome.com/69abb77bd4.js" crossorigin="anonymous"></script>
<style>
* {margin: 0;}
</style>
<div class="mock_exams">
<h3 class="mock_exams_heading">Download AB Mock Exams</h3>
</div>
<div class="mock_exams_container">
<h4 class="mock_exams_title">MOCK EXAMS</h4>
<div class="mock_panel">
<a class="mock_link" href="#" target="_blank">
<p class="pdf_stamp"><span class="pdf_stamp_name">PDF</span></p>
<div class="mock">
<p class="mock_name">
<span class="mock_name_text">
Mock AB Mock AB Mock AB Mock AB Mock AB Mock AB Mock AB Mock AB Mock AB
</span>
<span class="mock_pdf_icon"><i class="fas fa-download"></i></span>
</p>
</div>
</a>
<a class="mock_link" href="#" target="_blank">
<p class="pdf_stamp"><span class="pdf_stamp_name">PDF</span></p>
<div class="mock">
<p class="mock_name"><span class="mock_name_text">Mock AB</span><span class="mock_pdf_icon"><i class="fas fa-download"></i></span></p>
</div>
</a>
</div>
</div>
<iframe name="sif3" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>