simoal Posted July 12 Share Posted July 12 Hello, I added a text that includes font awesome symbols to the right side of my header with css code. It's a phone number and a mailadress. How to I make this text clickable so a click on the phone number leads to a call and a click on the mailadress leader to a mailto. Here is the Code I added: .header-container { position: relative; /* The parent container for the logo and the pseudo element */ } .header-title-logo { position: relative; /* Ensures that the pseudo-elements are positioned relative to the header */ } @media (min-width: 1024px) { .header-title-logo::after { content: "\f095\00a0\00a0 08032 70 76 55 \a \f0e0\00a0\00a0 info@schweinsteiger-bau.de" !important; /* Font Awesome Unicode for phone icon and email icon with the rest of the text */ font-family: Gendis, 'Font Awesome 5 Free'; /* Ensures that both Font Awesome and Gendis are used */ font-weight: 400; /* Necessary for the correct display of the Font Awesome icons */ white-space: pre-line; /* Ensures that line breaks are taken into account in the content */ display: block; position: absolute; /* Enables free positioning of the pseudo element */ right: 0px; /* Adjust this value to set the exact position */ top: 50%; /* Vertical alignment in the center of the container */ transform: translateY(-50%); /* Vertical centering */ text-align: left; /* Ensures that the text remains left-aligned */ font-size: 1.2rem; color: white; line-height:170%; padding-top: 10px; /* Optional, if required */ } } Thanks for the help! Link to comment
simoal Posted July 12 Author Share Posted July 12 Hi @tuanphan , can you maybe help? It would be really helpful. thank you sooo much! Link to comment
tuanphan Posted July 15 Share Posted July 15 CSS code can't solve this. You can share site url & let me know which text you want to add, I can give another code. Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
simoal Posted July 15 Author Share Posted July 15 Thank you! So html will be the solution? Here is the site: https://fjord-media-schweinsteiger.squarespace.com (Password: Demo) Link to comment
tuanphan Posted July 17 Share Posted July 17 On 7/15/2024 at 5:37 PM, simoal said: Thank you! So html will be the solution? Here is the site: https://fjord-media-schweinsteiger.squarespace.com (Password: Demo) It requires <script> code Use this code to Website Tools > Code Injection > FOOTER DO NOT add code to CSS box <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script> <script> $(document).ready(function(){ $('<div class="header-custom-info"><a href="tel:08032707655">08032 70 76 55</a><a href="mailto:info@schweinsteiger-bau.de"><i class="fa-regular fa-envelope"></i> info@schweinsteiger-bau.de</a></div>').appendTo('.header-actions.header-actions--right'); }); </script> <style> .header-actions.header-actions--right { display: flex !important; position: absolute; right: 0; } .header-title-logo::after { display: none !important; } .header-actions-action.header-actions-action--social { display: none !important; } .header-custom-info>a:nth-child(1) { margin-left: 20px; } </style> Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
Solution simoal Posted July 17 Author Solution Share Posted July 17 1 hour ago, tuanphan said: It requires <script> code Use this code to Website Tools > Code Injection > FOOTER DO NOT add code to CSS box <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script> <script> $(document).ready(function(){ $('<div class="header-custom-info"><a href="tel:08032707655">08032 70 76 55</a><a href="mailto:info@schweinsteiger-bau.de"><i class="fa-regular fa-envelope"></i> info@schweinsteiger-bau.de</a></div>').appendTo('.header-actions.header-actions--right'); }); </script> <style> .header-actions.header-actions--right { display: flex !important; position: absolute; right: 0; } .header-title-logo::after { display: none !important; } .header-actions-action.header-actions-action--social { display: none !important; } .header-custom-info>a:nth-child(1) { margin-left: 20px; } </style> Thank you. This is what finally worked for me: <!-- Text in Header clickable --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script> <script> $(document).ready(function(){ // Define the HTML content to be added to the header var customInfoHtml = '<div class="header-custom-info">' + '<a href="tel:08032707655">' + '<i class="fa-solid fa-phone"></i> 08032 70 76 55' + '</a>' + '<a href="mailto:info@schweinsteiger-bau.de">' + '<i class="fa-solid fa-envelope"></i> info@schweinsteiger-bau.de' + '</a>' + '</div>'; // Append the custom HTML content to the header actions container on the right $(customInfoHtml).appendTo('.header-actions.header-actions--right'); }); </script> <style> /* Ensure the header actions container on the right is flex and positioned absolutely to the right */ .header-actions.header-actions--right { display: flex !important; position: absolute; right: 0; } /* Remove any after pseudo-element from the header title logo */ .header-title-logo::after { display: none !important; } /* Hide the social actions in the header */ .header-actions-action.header-actions-action--social { display: none !important; } /* Style the custom header info links */ .header-custom-info a { margin-left: 0; /* Remove left margin to align links to the left */ display: block; /* Make each link a block element to appear on a new line */ font-size: 14px; /* Set font size to a smaller value */ line-height: 1.2; /* Reduce line height to decrease line spacing */ font-family: 'Gendis', sans-serif; /* Set font to Gendis */ margin-bottom: 4px; /* Add margin bottom to control spacing between links */ } /* Ensure the entire custom info container is left-aligned */ .header-custom-info { text-align: left; /* Align text to the left */ } /* Media query to hide the custom info container on screens smaller than 768px */ @media (max-width: 768px) { .header-custom-info { display: none; /* Hide the custom info on mobile devices */ } } </style> <!-- Text in Header clickable --> Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment