javascript - <p> JS/CSS 文本翻转器中的间距问题

标签 javascript css wordpress

我正在尝试制作一个歧义图制作工具,以大写字母和其他字体显示文本,无论是正面朝上还是正面朝下。我设法做到了这一点,但是单词之间的间距很大。有什么办法让它接近于零吗?我尝试在 css 中添加一些边距,但它似乎忽略了它。

它是作为 WordPress 插件制作的。您可以在此处看到它正在运行:https://makeambigrams.com/demo/

<?php
add_shortcode( 'worder', 'worder_print_html' );
function worder_print_html( ) {
    wp_enqueue_script('worder-script');
    ob_start();
    ?>
    <div class="the_worder_contaienr">
        <form method="post" id="word-er-form" name="word-er-form">
            <input type="text" name="word_er_word" id="word_er_word" value="" /> <br>
            <input type="submit" value="Generate" />
        </form>
        <div id="the_result">
        </div>
    </div>
    <style>
        .the_worder_contaienr {
            text-align: center;
            margin:0
            margin-top: -20px;
        }
        .the_worder_contaienr input{
            margin:0
        }
        p.origgina_other_font, .upside_down_font p {
            font-family: serif;
            margin:0
            margin-top: -20px;
        }
        .upside_down_uppwe,.upside_down,.upside_down_font  {
            transform: scaleY(-1);
            margin:0
            margin-top: -20px;
        }
    </style>
    <?php
    //$output = ob_end_clean();
    return ob_get_clean();
    //return "foo = {$atts['foo']}";
}
function the_worder_jquery() {
    wp_register_script( 'worder-script', plugin_dir_url( __FILE__ ) . '/custom.js', array( 'jquery' ), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'the_worder_jquery' );

js

(function($) {

  $('#word-er-form').on('submit', function() {
    event.preventDefault();
    var the_input = $('#word_er_word').val().toLowerCase();
    var the_characters = the_input.split('');
    console.table(the_characters);
    var the_original = $('#word_er_word').val();
    var the_upper_case = the_input.toUpperCase();
    var the_revese_case = the_characters.reverse().toString().replace(/,/g, "");;
    console.log(the_original);
    console.log(the_upper_case);
    console.log(the_revese_case);
    var the_result = '<p class="original">'+the_input+'</p>';
    the_result += '<p class="original_capitalize">'+the_upper_case+'</p>';
      the_result += '<p class="origgina_other_font">'+the_input+'</p>';
      the_result += '<div class="upside_down_font"><p>'+the_revese_case+'</p></div>';
            the_result += '<div class="upside_down_uppwe"><p>'+the_revese_case.toUpperCase()+'</p></div>';
      the_result += '<div class="upside_down"><p>'+the_revese_case+'</p></div>';
      $('#the_result').html(the_result);
  })

})( jQuery );

最佳答案

是的,这是可能的,为此您必须减少 <p> 的所有样式标签如下所示

p {
padding : 0px;
margin-top : 0px;
margin-bottom :0px;
height : 15px;

}

注意:请记住 <p> 的默认高度标签设置为 28px所以你也必须降低高度,否则仅通过其他样式它可能会显示一些空间。如果 style = "margin : ... "提到删除它。

希望这对您有帮助。

关于javascript - <p> JS/CSS 文本翻转器中的间距问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61029721/

相关文章:

css - 如何在不删除 :before pseudo element css 内的文本的情况下隐藏标签上的文本

javascript - 如何只点击模态外观而不点击对话框/内容?

javascript - 获取事件监听器内 e.target 子级的索引

javascript - 如何影响表格单元格以调整事件 div 的大小

python - Webdriver:当类名包含空格时如何查找元素?

javascript - 如何使用jquery根据输入类型数字字段数据显示另一个字段?

wordpress - WordPress 多站点中的管理员角色在保存页面时会删除内容

javascript - net::ERR_ABORTED) 如何解决模板插件中的 js 文件路径问题(将 Bootstrap 转换为 WordPress)

javascript - Axios POST 的发送状态和数据未显示在 req.body 中

javascript - 限制动态动画中的 FPS