I need to make a border like
with html and css. I tried to do it with display table, with visibility hidden, but none of it worked!
<div id="border">
<div id="visible">
<p id="yellow">Просто выберите, что Вам нужно</p>
</div>
</div>
#yellow { color: #dbff12; }
#border { border: 30px solid black; visibility: hidden; }
#visible { position: relative; bottom: 50px; visibility: visible; }
upd: what I mean is that I need a two hollow places around yellow text like on a picture
In this case it's convenient to use fieldset element with associated legend:
fieldset {
border: 4px green solid;
}
fieldset legend {
padding: 0 10px;
}
<fieldset>
<legend>Просто выберите, что вам нужно</legend>
<div>
Оформить тендер и т.п.
</div>
</fieldset>
Try This:
fieldset {
width: 300px;
border:3px solid skyblue;
}
legend {
color: orange;
padding: 0 10px;
}
span {
border-bottom: 1px dashed;
margin-right: 50px;
}
<fieldset>
<legend>Просто выберите, что Вам нужно</legend>
<span>Other Text</span>
<span>Other Text</span>
</fieldset>
You could also use a real title, flex to draw the top borders and the other borders from the container itself....
html {
min-height: 100%;
background: linear-gradient(to top left, rgba(0, 0, 0, 0.3), rgba(0, 125, 255, 0.5)), url(http://lorempixel.com/800/600/people/9) top center / cover;
}
[data-fieldset] {
width: 600px;
font-size: 20px;
color: rgba(15, 215, 255, 0.9);
text-shadow: 1px 1px 1px black;
margin: 4em auto 1em;
padding: 1em;
/* prepare border */
border: solid 10px rgba(15, 215, 255, 0.4);
border-top: none;
}
[data-fieldset] h1 {
font-size: 40px;
height: 40px;
line-height: 40px;
/* reset in position title */
margin: -35px -20px 1em;
/* prepare the pseudo behavior */
display: flex;
align-items: center;
color: rgba(255, 215, 16, 0.7);
}
/* draw the tops border via pseudo flex children */
[data-fieldset] h1:before,
[data-fieldset] h1:after {
content: '';
flex: 1;
background: rgba(15, 215, 255, 0.4);
height: 10px;
}
/* give some space to text */
[data-fieldset] h1:before {
margin-right: 0.5em;
}
[data-fieldset] h1:after {
margin-left: 0.5em;
}
<div data-fieldset>
<h1>My example</h1>
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est.
Mauris placerat eleifend leo.</p>
</div>
Related
After moving things around, I tried to change the position: absolute to position: relative of the actual iframe class, it made the video position under 'Featured' but the dimension of the video is messed up. If I change it back to position: absolute, the video covers the entire page banner, but the responsiveness is good, however the dimension is too big. How do I make it look like the video is under the Featured page, aligned in the center, and responsive as well?
This is my code:
#import url('https://fonts.googleapis.com/css2?family=Playfair+Display&display=swap');
#import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght#300&display=swap');
/*setting font size as 62.5%=10px for easier REM fontsize calculations*/
html, body {
font-size: 62.5%;
height: 100%;
margin: 0;
font-family: font-family: 'Playfair Display', serif;
}
/*making the image parallax as a banner*/
.parallax1 {
background: url(https://i.imgur.com/6wPsROo.png);
min-height: 100%;
background-position: center;
position: relative;
opacity: .95;
background-size: cover;
background-repeat: no-repeat;
background-attachment: fixed;
top: 0;
}
* {
padding: 0;
margin: 0;
text-declaration: none;
list-style: none;
box-sizing: border-box;
}
body {
background-color: white;
}
/*customizing banner text*/
#slogan {
font-size: 4.5rem;
color: white;
text-shadow: 1px 1.5px 1px #A26B40;
font-weight: lighter;
}
.heading2 {
width: 100%;
height: auto;
left: 0;
top: 50%;
position: absolute;
text-align: center;
line-height: 3.2rem;
}
#slogan-subheading {
font-size: 2.5rem;
color: white;
text-shadow: .5px .5px 1px #A26B40;
font-weight: lighter;
}
#shop-now {
background-color: #bd8d58;
width: 10%;
height: auto;
margin: 0 auto;
position: relative;
padding: 0px;
color: white;
font-family: 'Open Sans', sans-serif;
font-size: 1rem;
}
#shop-now:hover {
cursor: pointer;
}
/*make container for each row comprising an image with caption side by side*/
.prod-container {
flex-direction: row;
display: flex;
padding: 10px 20px;
text-align: center;
justify-content: center;
}
/*customize each cell*/
.image-and-capt {
padding: 10px 40px;
}
/*customize productimg*/
#product-img {
width: 200px;
border-radius: 50%;
box-shadow: 3px 5px 15px rgba(182,124,72,0.3);
}
/*customize product name & description*/
#product-name, #product-descrp {
font-family: 'Open Sans', sans-serif;
text-align: center;
font-weight: 800;
font-weight: bold;
color: rgba(54, 46, 39, 0.8);
}
#product-name {
font-size: 1.5rem;
padding-top: 10px;
}
#product-descrp {
font-size: 1rem;
padding-top: 4px;
}
.featured-container {
background: rgba(255, 214, 170, 0.6);
padding: 50px 100px;
}
.vid-container {
position: relative;
width: 100%;
overflow: hidden;
padding-bottom: 56.25%;
padding-top: 30px;
height: 0;
}
.vid-container-iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
bottom: 0;
right: 0;
display: block;
margin: 0 auto;
}
/*centering the logo and customizing size*/
#header-img {
max-width: 200px;
max-height: auto;
height: auto;
width: auto;
padding: 10px 0px 0px 0px;
}
/*customizing the navigation links*/
.nav-link {
text-decoration: none;
color: #54473C;
font-family: 'Playfair Display', serif;
display: column;
font-size: 1.5rem;
}
/*customizing the actual navigation bar*/
#nav-bar {
background-color: rgb(248, 234, 203);
height: 80px;
width: 100%;
padding: 0px 20px 0px 50px;
z-index: 1000;
position: fixed;
top: 0;
width: 100%;
transition: 0.6s;
}
/*aligning the nav links on the right of the header image*/
nav ul {
float: right;
padding: 0px 20px;
}
/*aligning the links to become horizontally aligned next to each other*/
nav ul li {
display: inline-block;
padding: 25px 10px 5px 50px;
margin-left: 0px;
}
/* customizing appearance of nav-links when hovered*/
.nav-link:hover, nav-link:focus {
background-color: #dcbd85;
padding: 8px;
border-radius: 5px;
transition: .5s;
color: white;
}
/* customizing nav-link when focused or clicked */
.nav-link:focus {
background-color: #dcbd85;
padding: 8px;
border-radius: 5px;
color: white;
}
/* customizing the three bars, making it invisible if in default full page view */
.check-bar {
font-size: 2.5rem;
color: #BF8D7A;
float: right;
cursor: pointer;
margin-right: 5px;
line-height: 80px;
display: none;
}
/*making the checkbox invisible, this checkbox is used as a condition later, that when checked itll make the navlinks appear in a a specific media query*/
#check {
display: none;
}
body, html {
height: 100%;
}
.products-container {
background: #f6f7e9;
padding: 50px 80px;
}
#sections {
font-family: 'Open Sans', sans-serif;
text-align: center;
width: 45%;
font-weight: 800;
font-size: 4rem;
margin: 0 auto;
text-transform: uppercase;
font-weight: lighter;
color: rgba(54, 46, 39, 0.5);
width: 100%;
text-align: center;
border-bottom: 1px solid rgba(54, 46, 39, 0.1);
line-height: 0.1em;
margin: 10px 0 20px;
}
h2 span {
background: #f6f7e9;
padding: 0 10px;
}
#media (max-width: 792px){
.nav-link{
font-size: 1.3rem;
}
#header-img{
max-width: 175px;
max-height: auto;
}
}
#media (max-width: 712px){
.nav-link{
font-size: 1.2rem;
}
#header-img{
max-width: 150px;
max-height: auto;
}
}
#media (max-width: 675px){
.nav-link{
font-size: 1.3rem;
}
#header-img{
max-width: 150px;
max-height: auto;
}
nav ul li {
padding: 25px 10px 5px 50px;
margin-left: -30px;
}
}
#media (max-width: 675px){
.nav-link{
font-size: 1.1rem;
}
#header-img{
max-width: 150px;
max-height: auto;
}
nav ul li {
padding: 25px 10px 5px 50px;
margin-left: -40px;
}
}
/*configure what happens when you click three bars*/
#media (max-width: 500px){
.check-bar{
display: block;
}
/*center the logo , not yet done */
#header-img {
max-width: 200px;
max-height: auto;
display: block;
margin: auto;
}
ul{
position: fixed;
width: 100%
height: 100vh;
top: 80px;
/*when three bars are clicked the left bottom right values makes the whole ul disappear*/
left: -100%;
bottom: -100%;
right: 100%;
text-align: center;
background: rgba(255, 214, 170, 0.9);
transition: all .5s;
/* for stack, this makes the ul box in front of the parallax image since its z index is greater than the parallax*/
z-index: 2;
}
nav ul li {
display: block;
padding: 20px;
}
.nav-link {
font-size: 1.6rem;
font-weight: bold;
margin-left: 60px
}
#check:checked ~ul {
left: 0;
right: 0;
bottom: 0;
}
.nav-link:hover {
background: none;
color: #BF8D7A;
}
.parallax1 {
z-index: 1;
}
}
#media (max-width: 467px){
#header-img{
max-width: 190px;
}
.nav-link {
font-size: 1.6rem;
}
}
#media (max-width: 314px){
#header-img{
max-width: 200px;
margin: auto auto 0px auto;
padding-top: 10px;
}
.nav-link {
font-size: 1.2rem;
}
.check-bar {
font-size: 1.8rem;
}
#nav-bar {
padding-left: 10px;
}
}
#media (max-width: 271px){
#header-img{
max-width: 200px;
margin: auto auto 0px 0px;
padding-top: 5px;
}
.nav-link {
font-size: 1.2rem;
}
.check-bar{
font-size: 1.8rem;
}
#nav-bar {
padding-left: 10px;
}
}
#media (max-width: 251px){
#header-img{
max-width: 180px;
padding-top: 10px;
padding-left: 0px;
padding-right: 0px;
margin: 0px;
}
.nav-link {
font-size: 1.2rem;
}
#nav-bar {
padding-left: 8px;
}
.check-bar {
font-size: 1.8rem;
padding-top: 0px;
}
}
<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
<body>
<header id="header">
<nav id="nav-bar">
<input type="checkbox" id="check">
<label for="check" class="check-bar">
<i class="fas fa-bars"></i>
</label>
<img id="header-img" src="https://i.imgur.com/zxchwt8.gif">
<ul>
<li id="nav-links-list"><a class="nav-link" href="#the-products">products</a></li>
<li id="nav-links-list"><a class="nav-link" href="#featured" target=_blank>featured</a></li>
<li id="nav-links-list"><a class="nav-link" href="#pricing" target=_blank>pricing</a></li>
<li id="nav-links-list"><a class="nav-link" href="#contacts" target=_blank>contact</a></li>
</ul></nav></header>
<div class="parallax1">
<div class="heading2">
<span class="border">
<h1 id="slogan">Pamper your skin.</h1>
<h3 id="slogan-subheading">Cruelty-free, environmentally conscious, and organic. </h3>.
<span id="box"><h4 id="shop-now">SHOP NOW</h4></span
</div>
</div>
<div class="products-container">
<section id="the-products">
<h2 id="sections"><span>products</span></h2>
<div class="image-and-capt">
<div class="prod-container">
<div class="image-and-capt">
<img id="product-img" src="https://i.imgur.com/iSuRo4f.png" alt ="mock-up foundation">
<h3 id="product-name"> Foundation with SPF 50 </h3>
<p id="product-descrp"> Medium-coverage, long-lasting, and available in 50 shades.
</div>
<div class="image-and-capt">
<img id="product-img" src="https://i.imgur.com/KSXpO9w.png" alt="moisturizer">
<h3 id="product-name"> Moisturizer for All Skin Types</h3>
<p id="product-descrp"> Nourishing and brightening, reduces appearance of fine lines and wrinkles.
</div>
</div>
<div class="prod-container">
<div class="image-and-capt">
<img id="product-img" src="https://i.imgur.com/cqzlfal.png" alt ="mock-up tinted moisturizer">
<h3 id="product-name"> Tinted Moisturizer </h3>
<p id="product-descrp"> Light-coverage with 50 shades, nourishing and brightening.
</div>
<div class="image-and-capt">
<img id="product-img" src="https://i.imgur.com/UdInLk3.png" alt ="mock-up face wash">
<h3 id="product-name"> Facewash </h3>
<p id="product-descrp"> Gentle and hydrating facewash, thourougly cleanses dirt, make-up and sebum.</p>
</div>
</div>
</section>
</div>
<section id="featured">
<div class="featured-container">
<h2 id="sections">featured</h2>
<div class"vid-container">
<iframe class="vid-container-iframe" src="https://www.youtube.com/embed/MJMMZvBK6nU?autoplay=1&showinfo=0&rel=0&color=white" width="560" height="315" frameborder="0"></iframe>
</div>
</section></div>
<section id="pricing">
<p>Nam fermentum risus libero, ac ultricies leo faucibus nec. Nulla rhoncus nulla massa, dignissim finibus magna bibendum a. Morbi et aliquet justo, eu sagittis lectus. Quisque orci ipsum, aliquet ornare porttitor eget, fringilla quis purus. Integer eu semper eros. Donec quis libero at diam eleifend porttitor rutrum eu ipsum. Mauris sapien ipsum, gravida non ipsum sit amet, viverra facilisis mauris. Proin lacinia lectus vitae interdum condimentum. Quisque viverra sit amet diam ut finibus. Etiam nec ullamcorper magna.</p>
</section>
<section id="contact">
<p>Nam fermentum risus libero, ac ultricies leo faucibus nec. Nulla rhoncus nulla massa, dignissim finibus magna bibendum a. Morbi et aliquet justo, eu sagittis lectus. Quisque orci ipsum, aliquet ornare porttitor eget, fringilla quis purus. Integer eu semper eros. Donec quis libero at diam eleifend porttitor rutrum eu ipsum. Mauris sapien ipsum, gravida non ipsum sit amet, viverra facilisis mauris. Proin lacinia lectus vitae interdum condimentum. Quisque viverra sit amet diam ut finibus. Etiam nec ullamcorper magna.</p>
</section>
</div>
</header>
</body>
Your code is a mess to be honest. You have multiple div without closing tag,p without closing tags,
also some = are missing while declaring classes in your html code.
First go through your code, make sure that every single tag has a closing tag, after that continue with your video because if you dont fix these things, then your responsivity will be broken because of those unclosed tags.
Have a look into that, i have fixed the video so now it is under your featured section, you just have to play around with it to make it responsive after you closed every unclosed tag.
<section id="featured">
<div class="featured-container">
<h2 id="sections">featured</h2>
<div class="vid-container">
<iframe class="vid-container-iframe"
src="https://www.youtube.com/embed/MJMMZvBK6nU?autoplay=1&showinfo=0&rel=0&color=white" width="560"
height="315" frameborder="0"></iframe>
</div>
</div>
</section>
I have a div that slides (out to left/in from left) when the toggle button is clicked on. I'm using Vue.js's transition component to handle the slide animation. The slide animation for the div works as intended, but my problem is that the toggle button doesn't stick with the div while it's sliding (out/in). Both are nested within a container.
Here's the codepen: https://codepen.io/chataolauj/pen/jOrOWpL
#app {
width: 100vw;
height: 100vh;
}
#container {
z-index: 1;
position: absolute;
width: 28%;
height: 100%;
display: flex;
background-color: white;
#event-list {
width: 100%;
height: 100%;
background: white;
box-shadow: 5px 5px 15px 0px rgba(0, 0, 0, 0.3);
}
.toggle-button {
margin-top: 8px;
height: 48px;
background-color: rgba(255, 255, 255, 0.9);
border-left: 1px solid #d4d4d4;
box-shadow: 3px -1px 7px 0px rgba(0, 0, 0, 0.3);
outline: none;
&:hover {
cursor: pointer;
background-color: rgba(255, 255, 255, .5);
}
}
}
.slide-in-out-enter-active {
animation: slide-in-out 0.5s reverse;
}
.slide-in-out-leave-active {
animation: slide-in-out 0.5s;
}
#keyframes slide-in-out {
0% {
transform: translateX(0%);
}
100% {
transform: translateX(-100%);
}
}
<div id="app">
<div id="container">
<transition name="slide-in-out">
<div v-if="toggle" id="event-list">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In imperdiet ante id finibus molestie. Mauris pharetra vel est id dictum. In varius, mi in interdum dignissim, nulla erat congue erat, viverra consequat felis libero vel sem. Pellentesque vel ex tristique, ultrices tortor vel, consequat erat. Nulla ornare porttitor nisl.</p>
</div>
</transition>
<button #click="toggle = !toggle" class="toggle-button">Toggle
</button>
</div>
</div>
EDIT: #Cuong Le Ngoc's answer did satisfy my question, but seeing the texting wrapping while the panel is "sliding" makes it seem more like a "shrink" transition than a "slide" transition. It's a dealbreaker for me. I'm trying to emulate Google Maps sliding panel.
You can use animation with width instead of transform: translateX(...) and use overflow-wrap: break-word; to prevent text overflow:
#event-list {
...
overflow-wrap: break-word;
}
And:
#keyframes slide-in-out {
0% {
width: 100%;
}
100% {
width: 0%;
}
}
Codepen
EDIT: You can use margin-left instead of width if you prefer slide transition
#keyframes slide-in-out {
0% {
margin-left: 0%;
}
100% {
margin-left: -100%;
}
}
Codepen
I'm trying to target the H3 tag within this sass class &.featured and I do not understand how to code it? Perhaps I misread the docs from css tricks?
tag<tag
Frontend
<div class="col-6 col-12-narrower">
<section>
<header>
<a class="image featured" href="/index.html"><h3>test one</h3></a>
</header>
<p>Sed tristique purus vitae volutpat commodo suscipit amet sed nibh. Proin a ullamcorper sed blandit. Sed tristique purus vitae volutpat commodo suscipit ullamcorper sed blandit lorem ipsum dolore.</p>
</section>
</div>
Sass
/* Image */
.image {
border: 0;
position: relative;
&:before {
content: '';
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
}
&.fit {
display: block;
img {
display: block;
width: 100%;
}
}
&.featured {
display: block;
margin: 0 0 2em 0;
background-image: linear-gradient(to bottom right, rgb(187, 171, 179), #3b3639);
padding:50px;
a>h3 {
font-size: x-large;
color: white;
}
}
&.logo {
display: block;
margin: 45px 0px .6em 0;
img {
display: inline;
max-width: 100%;
height: auto;
}
}
}
Your code in line with a>h3 means .featured a h3, but you need .featured h3 (a.featured h3).
Try
&.featured {
display: block;
margin: 0 0 2em 0;
background-image: linear-gradient(to bottom right, rgb(187, 171, 179), #3b3639);
padding:50px;
h3 {
font-size: x-large;
color: white;
}
}
I have following layout, but in rtl copy button goes to the left. How do I keep copy button on the right like it was no rtl?
I tried some solutions here but I cannot make it work: flexbox align column left and right
.data {
display: flex; /* displays flex-items (children) inline by default */
align-items: flex-start; /* vertical alignment / optional but recommended / if you don't want that flex-items match in height, which by default they do (default value of stretch, which makes them fill the flex-containers height and where the height of all items is dictated by the height of the "tallest" one) / you can also try the value of center */
max-width: 400px;
direction: rtl;
}
.code {
color: #fff;
margin: 0;
padding: 8px !important;
line-height: 1.2;
font-size: 11px;
background: #bbb;
border: 1px solid #333;
word-wrap: break-word;
/*float: left; not necessary*/
}
.copy {
color: #ccc;
/*display: inline-block; not necessary*/
padding: 3px !important;
font-size: 12px;
cursor: pointer;
border: 1px solid #999;
/*float: right; not necessary*/
margin-left: 10px; /* design purposes */
}
<div class="data">
<p class="code">Praesent molestie. Nunc Venenatis Sapien Ultrices Dui. Vivamus dolor. Integer vel ante. Proin felis. Maecenas non nisl eu mi hendrerit fringilla.</p>
<div class="copy">COPY</div>
</div>
Use the order property.
By default, all flex items are set to order: 0, which means their appearance in the source dictates their order in the layout.
You can change the visual order of flex items using positive and negative integers.
.data {
display: flex;
align-items: flex-start;
max-width: 400px;
direction: rtl;
}
.code {
color: #fff;
margin: 0;
padding: 8px !important;
line-height: 1.2;
font-size: 11px;
background: #bbb;
border: 1px solid #333;
word-wrap: break-word;
}
.copy {
order: -1; /* NEW */
color: #ccc;
padding: 3px !important;
font-size: 12px;
cursor: pointer;
border: 1px solid #999;
}
<div class="data">
<p class="code">Praesent molestie. Nunc Venenatis Sapien Ultrices Dui. Vivamus dolor. Integer vel ante. Proin felis. Maecenas non nisl eu mi hendrerit fringilla.</p>
<div class="copy">COPY</div>
</div>
Here's a more complete explanation and examples: https://stackoverflow.com/a/36118012/3597276
Of course, you can also achieve what you want by simply switching the order of the elements:
.data {
display: flex;
align-items: flex-start;
max-width: 400px;
direction: rtl;
}
.code {
color: #fff;
margin: 0;
padding: 8px !important;
line-height: 1.2;
font-size: 11px;
background: #bbb;
border: 1px solid #333;
word-wrap: break-word;
}
.copy {
color: #ccc;
padding: 3px !important;
font-size: 12px;
cursor: pointer;
border: 1px solid #999;
}
<div class="data">
<div class="copy">COPY</div><!-- now this element is listed first -->
<p class="code">Praesent molestie. Nunc Venenatis Sapien Ultrices Dui. Vivamus dolor. Integer vel ante. Proin felis. Maecenas non nisl eu mi hendrerit fringilla.</p>
</div>
You can just apply flex-direction: row-reverse to your flex container. In this case you don't have to set order for every flex item.
.data {
display: flex; /* displays flex-items (children) inline by default */
align-items: flex-start; /* vertical alignment / optional but recommended / if you don't want that flex-items match in height, which by default they do (default value of stretch, which makes them fill the flex-containers height and where the height of all items is dictated by the height of the "tallest" one) / you can also try the value of center */
max-width: 400px;
flex-direction: row-reverse; /* new */
}
.code {
color: #fff;
margin: 0;
padding: 8px !important;
line-height: 1.2;
font-size: 11px;
background: #bbb;
border: 1px solid #333;
word-wrap: break-word;
/*float: left; not necessary*/
}
.copy {
color: #ccc;
/*display: inline-block; not necessary*/
padding: 3px !important;
font-size: 12px;
cursor: pointer;
border: 1px solid #999;
/*float: right; not necessary*/
margin-left: 10px; /* design purposes */
}
<div class="data">
<p class="code">Praesent molestie. Nunc Venenatis Sapien Ultrices Dui. Vivamus dolor. Integer vel ante. Proin felis. Maecenas non nisl eu mi hendrerit fringilla.</p>
<div class="copy">COPY</div>
</div>
Please note that direction: rtl should be used for languages written from right to left (like Hebrew or Arabic), not for reversing your layout.
I have 2 elements which hold text, both are unknown width and I dont want to add fixed width to copy div.
How do I make them float in one line and always occupy 100% width together? (without tables)
.data{
max-width:400px;
}
.code {
color: #fff;
margin: 0;
padding: 8px!important;
line-height: 1.2;
font-size: 11px;
background: #bbb;
border: 1px solid #333;
word-wrap: break-word;
float: left;
}
.copy {
color: #ccc;
display: inline-block;
padding: 3px!important;
font-size: 12px;
cursor: pointer;
border: 1px solid #999;
float: right;
margin-top: 1px;
}
<div class="data">
<p class="code">Praesent molestie. Nunc Venenatis Sapien Ultrices Dui. Vivamus dolor. Integer vel ante. Proin felis. Maecenas non nisl eu mi hendrerit fringilla.</p>
<div class="copy">COPY</div>
</div>
You can do it with the Flexbox:
.data {
display: flex; /* displays flex-items (children) inline by default */
align-items: flex-start; /* vertical alignment / optional but recommended / if you don't want that flex-items match in height, which by default they do (default value of stretch, which makes them fill the flex-containers height and where the height of all items is dictated by the height of the "tallest" one) / you can also try the value of center */
max-width: 400px;
}
.code {
color: #fff;
margin: 0;
padding: 8px !important;
line-height: 1.2;
font-size: 11px;
background: #bbb;
border: 1px solid #333;
word-wrap: break-word;
/*float: left; not necessary*/
}
.copy {
color: #ccc;
/*display: inline-block; not necessary*/
padding: 3px !important;
font-size: 12px;
cursor: pointer;
border: 1px solid #999;
/*float: right; not necessary*/
margin-left: 10px; /* design purposes */
}
<div class="data">
<p class="code">Praesent molestie. Nunc Venenatis Sapien Ultrices Dui. Vivamus dolor. Integer vel ante. Proin felis. Maecenas non nisl eu mi hendrerit fringilla.</p>
<div class="copy">COPY</div>
</div>
Use can use flexible box to deal with this. Just need to add display:flex in your .data. For more info, please read here
.data{
max-width:400px;
display:flex;
}
.code {
color: #fff;
margin: 0;
padding: 8px!important;
line-height: 1.2;
font-size: 11px;
background: #bbb;
border: 1px solid #333;
word-wrap: break-word;
float: left;
}
.copy {
color: #ccc;
display: inline-block;
padding: 3px!important;
font-size: 12px;
cursor: pointer;
border: 1px solid #999;
float: right;
margin-top: 1px;
}
<div class="data">
<p class="code">Praesent molestie. Nunc Venenatis Sapien Ultrices Dui. Vivamus dolor. Integer vel ante. Proin felis. Maecenas non nisl eu mi hendrerit fringilla.</p>
<div class="copy">COPY</div>
</div>