
-
AuthorPosts
-
January 10, 2023 at 11:32 pm #1378185
Hallo togehter,
since a while I am a silent reader in this forum. The great contributions here could help me very often. Thanks for this :)
But now I can’t get any further. I have already tried a few things, but unfortunately none of the attempts have worked.I would like to set up a heading (H1 or H2) in such a way that it always takes on the width of the underlying text or the width of the column in which the heading and the text are contained.
Can someone give me a tip. I’m already so confused that I don’t even know if it’s possible at all :)
I would be very happy about an answer.
Many thanks in advance.
Kind regards
PaddySee screenshot in private content, with a simplified representation how I mean it :)
January 11, 2023 at 8:04 am #1378213Hey padweb,
Thank you for the inquiry.
Did you select centered layout in the Heading Style settings? Try selecting left or right layout to move the edge of the column instead of aligning the heading at the center of the column.
Best regards,
IsmaelJanuary 12, 2023 at 1:27 pm #1378388Hey Ismael,
thank you for your fast reply. Yes, actually the Heading Style is set to “centered”. I have tried what you mentioned above.The heading then moves to the appropriate edge (left or right), however my wish for the heading content (text) to stretch across the entire column width has
not yet been fulfilled. But as mentioned in the first post, I don’t even know if this is possible at all?Best regards,
PaddyJanuary 13, 2023 at 6:57 am #1378517Hi,
The heading then moves to the appropriate edge (left or right), however my wish for the heading content (text) to stretch across the entire column width has
not yet been fulfilled. But as mentioned in the first post, I don’t even know if this is possible at all?This is possible as long as the heading is not center aligned. You can also try and set the text alignment to “justify”. Please provide the site URL so that we can check the issue properly.
// https://developer.mozilla.org/en-US/docs/web/css/text-justify
Best regards,
IsmaelJanuary 13, 2023 at 10:03 am #1378545Hi,
okay. Thank you. I’ll try the justify setting for the text.
Here is the link to the page https://dev.melter-next-level.de/
Its in colorsection with 3 columns. In the middle column, centered heading and centered text. The heading above the text should be the same width like the text/column itself. It would be okay, if the aktual width of the text would be reduced a little, but not too much.
Thank you in advance.
Best regards,
Paddy
P.S. But finally, at least the Heading should be centered or look like it :)-
This reply was modified 2 years, 6 months ago by
padweb.
January 14, 2023 at 11:42 pm #1378712Hi,
Thank you for your patience, to center the special heading and the subheading below it try adding this css to your Enfold Theme Options ▸ General Styling ▸ Quick CSS field:#support .flex_column_table h1.av-special-heading-tag { text-align: center; } #support .flex_column_table .av-special-heading .av-subheading_below { text-align: center; }
Then to make the special heading full width add this code to the end of your child theme functions.php file in Appearance ▸ Editor:
function custom_stretch_text_script() { ?> <script> (function($) { $.fn.stretch_text = function(){ var elmt = $(this), cont_width = elmt.width(), txt = elmt.html(), one_line = $('<span class="stretch_it">' + txt + '</span>'), nb_char = elmt.text().length, spacing = cont_width/nb_char, txt_width; elmt.html(one_line); txt_width = one_line.width(); if (txt_width < cont_width){ var char_width = txt_width/nb_char, ltr_spacing = spacing - char_width + (spacing - char_width)/nb_char ; one_line.css({'letter-spacing': ltr_spacing}); } else { one_line.contents().unwrap(); elmt.addClass('justify'); } }; $(document).ready(function () { $('#support .av-special-heading-tag').each(function(){ $(this).stretch_text(); }); }); }(jQuery)); </script> <?php } add_action('wp_footer', 'custom_stretch_text_script');
Please see the screenshot in the Private Content area.
Best regards,
MikeJanuary 16, 2023 at 7:35 am #1378819Hello Mike,
thanks a mill for your support. I have tried exactly the steps you mentioned above. The css part seem to be working. The heading and subheading gets centered (its originally set to left).But the jquery part doesn’t seem to be working. The heading doesn’t stretch to the content width.
What did i do wrong? :)
Best regards;
PaddyJanuary 16, 2023 at 1:34 pm #1378862Hi,
Thanks for the feedback, I don’t see the javascript in your page source code, please ensure it is in your child theme functions.php file and that you copied the code from the forum and not an email notification so the symbols were not converted.
In the code you should see > and not >
If this looks correct please include an admin login in the Private Content area below so we can assist further.Best regards,
MikeJanuary 16, 2023 at 1:43 pm #1378868Hi Mike,
i have copied the css and the code directly from your post, not from the notification email.
I pasted it into the functions.php from the enfold child theme.
Pleas see admin login data in the Private Content area.
Thank you in advance.
Best regards,
PaddyJanuary 16, 2023 at 3:01 pm #1378883Hi,
Thanks for the login, I made an error in the code I posted above, I corrected and it’s now working, please check.Best regards,
MikeJanuary 17, 2023 at 10:13 am #1388020Hi Mike,
thank you very much again. No it seems to be working and it look good. Like the way it should be :)
Perfect.
Thanks!Best regars,
PaddyJanuary 17, 2023 at 12:56 pm #1388040Hi,
Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
This reply was modified 2 years, 6 months ago by
-
AuthorPosts
- The topic ‘Heading (f.e. H1, ..) same width as text/content’ is closed to new replies.