你怎么把div放在右边
How do you put the div to the right
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/0.7.4/tailwind.min.css" rel="stylesheet" />
<header class="bg-red p-5 flex border-b-2 border-white border-b-4">
<h1 class="font-display text-white text-md tracking-tight font-medium uppercase">local app</h1>
<div id="profile">
<img class="h-16 w-16 rounded-full mb-2 border-white border-4" src="{{ asset('assets/images/avatar.jpg') }}" alt="">
</div>
</header>
我想把那个头像放在最右边的“APP”旁边,但是好像不行
尝试在 <div id="profile">
上使用 margin-left:auto; margin-right:0;
#profile{
margin-left: auto;
margin-right: 0;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/0.7.4/tailwind.min.css" rel="stylesheet" />
<header class="bg-red p-5 flex border-b-2 border-white border-b-4">
<h1 class="font-display text-white text-md tracking-tight font-medium uppercase">local app</h1>
<div id="profile">
<img class="h-16 w-16 rounded-full mb-2 border-white border-4" src="{{ asset('assets/images/avatar.jpg') }}" alt="">
</div>
</header>
您可以在图像容器上使用绝对位置并将 right
设置为 1rem
或类似的。 right
属性控制元素应放置在距右侧多远的位置。 (但还有许多其他方法可以做到这一点)
header {
position: relative;
}
#profile {
position: absolute;
right: 1rem;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/0.7.4/tailwind.min.css" rel="stylesheet" />
<header class="bg-red p-5 flex border-b-2 border-white border-b-4">
<h1 class="font-display text-white text-md tracking-tight font-medium uppercase">local app</h1>
<div id="profile">
<img class="h-16 w-16 rounded-full mb-2 border-white border-4" src="{{ asset('assets/images/avatar.jpg') }}" alt="">
</div>
</header>
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/0.7.4/tailwind.min.css" rel="stylesheet" />
<header class="bg-red p-5 flex border-b-2 border-white border-b-4">
<h1 class="font-display text-white text-md tracking-tight font-medium uppercase">local app</h1>
<div id="profile">
<img class="h-16 w-16 rounded-full mb-2 border-white border-4" src="{{ asset('assets/images/avatar.jpg') }}" alt="">
</div>
</header>
我想把那个头像放在最右边的“APP”旁边,但是好像不行
尝试在 <div id="profile">
margin-left:auto; margin-right:0;
#profile{
margin-left: auto;
margin-right: 0;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/0.7.4/tailwind.min.css" rel="stylesheet" />
<header class="bg-red p-5 flex border-b-2 border-white border-b-4">
<h1 class="font-display text-white text-md tracking-tight font-medium uppercase">local app</h1>
<div id="profile">
<img class="h-16 w-16 rounded-full mb-2 border-white border-4" src="{{ asset('assets/images/avatar.jpg') }}" alt="">
</div>
</header>
您可以在图像容器上使用绝对位置并将 right
设置为 1rem
或类似的。 right
属性控制元素应放置在距右侧多远的位置。 (但还有许多其他方法可以做到这一点)
header {
position: relative;
}
#profile {
position: absolute;
right: 1rem;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/0.7.4/tailwind.min.css" rel="stylesheet" />
<header class="bg-red p-5 flex border-b-2 border-white border-b-4">
<h1 class="font-display text-white text-md tracking-tight font-medium uppercase">local app</h1>
<div id="profile">
<img class="h-16 w-16 rounded-full mb-2 border-white border-4" src="{{ asset('assets/images/avatar.jpg') }}" alt="">
</div>
</header>