简体   繁体   English

我如何将雪佛龙移到最右边并与文本保持一定距离?

[英]How do i move the chevron to the far right with a distance to the text?

How can I get the toggle button / Chevron to the far right?我怎样才能把切换按钮/雪佛龙放在最右边?

How it looks now:现在的样子: 现在的样子

How I want it to look:我希望它看起来如何:

我希望它看起来如何

I made it with the example accordion from the svelte docs .我使用svelte docs中的示例手风琴制作了它。

Any help is appreciated任何帮助表示赞赏

<script>
    import { slide } from "svelte/transition";
    export let entry
    let isOpen = false
    const toggle = () => isOpen = !isOpen
</script>
<style>
    button {
        border: none; 
        background: none;
        display:block; 
        color: inherit; 
        font-size: 16px; 
        cursor: pointer; 
        margin: 0; 
        padding-bottom: 0.5em; 
        padding-top: 0.5em;
        padding-left: 0;
    }
    ul {
        list-style-type: none;
        padding-left: 0;
    }
    li {
        font-size: 16px;
        font-weight: 300;
        
    }
    svg { 
        transform: rotate(90deg);
        transition: transform 0.2s ease-in;
        margin-right: 0;   
    }
    
    [aria-expanded=true] svg { transform: rotate(0.75turn); }
</style>
<button on:click={toggle} aria-expanded={isOpen}> {entry[0]}<svg style="tran"  width="20" height="20" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24" stroke="currentColor"><path d="M9 5l7 7-7 7"></path></svg> </button>
{#if isOpen}
<ul transition:slide={{ duration: 300 }}>
    {#each entry[1] as item}
    <li>{item}</li>
    {/each}
</ul>
{/if}

The simplest solution is to use flexbox and space-between .最简单的解决方案是使用flexboxspace-between

 .accordion { display: flex; justify-content: space-between; }
 <div class="accordion"> text <svg width="18" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" /> </svg> </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM