I have been trying for a while now and cant seem to achive the bellow design:
.exploreItem {
background-color: #353258;
/* rgba(31, 31, 31, 1) */
border: 1px solid #4152F1;
color: white;
/* padding: 20px 24px; */
cursor: pointer;
width: 90%;
height: 45px;
/* font-size: 15px;
font: Arial;
font-family: sans-serif;
display: block; */
}
.exploreImg {
/* background-color: lightblue; */
display: inline-block;
vertical-align: top;
height: 30px;
/* width: 10px; */
padding-left: 10px;
}
.exploreLabel {
/* vertical-align: middle; */
/* background-color: grey; */
display: inline-block;
font-size: 15px;
font: Arial;
font-family: sans-serif;
/* width: 10px; */
margin-top: 0px;
}
<div class="exploreItem" id="exploreItem">
<img class="exploreImg" src="images/defaultProfImg.png">
<label class="exploreLabel">Explore</label>
</div>
How can I create the intended design layout? (An image next to the explore label like in the image)
You even don't need the image just use css to do it. And even if you use image you can use display: flex for .exploreItem and align-items: center can do the magic.
I had put down the simpler css only solution here with :before pseudo element.
.exploreItem {
background-color: #353258;
border: 1px solid #4152F1;
color: white;
cursor: pointer;
padding: 16px;
width: 90%;
border-radius: 32px;
}
.exploreLabel {
display: flex;
align-items: center;
font-size: 15px;
font: Arial;
font-family: sans-serif;
margin-top: 0px;
}
.exploreLabel:before {
content: '';
height: 28px;
width:28px;
background-color: #4152F1;
border: 1px solid #a89dff;
display: block;
margin-right: 16px;
border-radius: 50%;
}
<div class="exploreItem" id="exploreItem">
<label class="exploreLabel">Explore</label>
</div>
.wrapper {
width: 200px;
}
.exploreItem {
width: 100%;
display: flex;
background: transparent;
padding: 20px 30px;
border: 1px solid transparent;
border-radius: 50px;
align-items: center;
cursor: pointer;
}
.exploreItem label {
color: #919191;
}
.exploreItem.active {
display: flex;
background: #2F2D50;
border: 1px solid #483EF1;
}
.exploreItem.active label {
color: #ffffff;
}
.exploreItem i {
display: block;
background: #A3A3A3;
border: 1px solid transparent;
width: 25px;
height: 25px;
border-radius: 50px;
margin-right: 10px;
}
.exploreItem.active i {
background: #483EF1;
border: 1px solid #A5A0FF;
}
<div class="wrapper">
<div class="exploreItem active">
<i></i>
<label class="exploreLabel">Explore</label>
</div>
<div class="exploreItem">
<i></i>
<label class="exploreLabel">Explore</label>
</div>
</div>
Use below code:
HTML:
<div class="outer">
<div class="round"></div>
<label>
<span>Explore</span>
</label>
</div>
CSS:
.outer
{
background: #353258;
border: 1.5px solid #4152F1;
color: white;
padding: 7px 8px;
cursor: pointer;
width: 150px;
height:33px;
border-radius: 30px;
cursor: pointer;
}
.round
{
background: #502ffb;
height: 28px;
width: 28px;
display: inline-block;
border: 1px solid white;
border-radius: 50%;
}
label
{
color: white;
display: inline-block;
cursor: pointer;
}
label span
{
position: absolute;
margin-top: -24px;
margin-left: 3px;
font-size: 17px;
}
Related
I'm just wondering how I can put my button at the right-bottom of the parent box.
I have put position: relative; to the parent box and used position: absolute; for the button class.
This worked perfectly. However, the button overlapped with the contents of the parent box.
What would be the best way to fix this?
Here's my html and css Thank you!!
.color {
border: 1px solid black;
width: 70%;
margin: 10px auto;
padding: 0 30px;
position: relative;
}
.color p {
display: inline-block;
width: 200px;
height: 80px;
margin-right: 10px;
text-align: center;
line-height: 78px;
}
p.black {
background: black;
color: white;
}
p.gray {
background: gray;
color: white;
}
p.blue {
background: blue;
color: white;
}
p.white {
border: 1px solid black;
}
.btn {
position: absolute;
right: 10px;
bottom: 10px;
}
.btn a {
display: inline-block;
background: #efd9ca;
padding: 25px;
width: 300px;
text-align: center;
text-decoration: none;
}
<h1 class="heading">color</h1>
<p class="black">black</p>
<p class="gray">gray</p>
<p class="white">white</p>
<p class="blue">blue</p>
<div class="btn">Mozilla color collection website</div>
I removed your relative and absolute position declarations. Then I added following css declrations:
.btn {
float: right;
margin-bottom: -20px;
}
float: right; will align the button to the right side. With margin-bottom: -20px; you counter the padding bottom of 30px so that the spacing will only be 10px as previos attempted.
.color {
border: 1px solid black;
width: 70%;
margin: 10px auto;
padding: 0 30px;
}
.color p {
display: inline-block;
width: 200px;
height: 80px;
margin-right: 10px;
text-align: center;
line-height: 78px;
}
p.black {
background: black;
color: white;
}
p.gray {
background: gray;
color: white;
}
p.blue {
background: blue;
color: white;
}
p.white {
border: 1px solid black;
}
.btn a {
display: inline-block;
background: #efd9ca;
padding: 25px;
width: 300px;
text-align: center;
text-decoration: none;
}
.btn {
float: right;
margin-bottom: -20px;
}
<h1 class="heading">color</h1>
<p class="black">black</p>
<p class="gray">gray</p>
<p class="white">white</p>
<p class="blue">blue</p>
<div class="btn">Mozilla color collection website</div>
Need to make two buttons align a few pixels left and right of the centre
I need div left to be 1px to the left of the centre. And right to be 1px right of it.
Any ideas how?
.btn {
font-family: helvetica;
font-weight: bolder;
padding: 10px;
border-radius: 2px;
color: black;
border: 2px solid black;
background-color: white;
width: 100px;
text-decoration: none;
}
.btn2 {
font-family: helvetica;
font-weight: bolder;
padding: 10px;
border-radius: 2px;
color: white;
border: 2px solid white;
background-color: black;
width: 100px;
text-decoration: none;
}
.divleft {
margin: auto 0;
text-align: left;
}
.divright {
margin: auto 0;
text-align: right;
}
<div class="divleft"> Memento </div>
<div class="divright"> Mori </div>
Use flexbox:
.box {
display: flex;
width: 100%;
}
.left,
.right {
width: 100%;
}
.left {
text-align: right;
margin-right: 10px;
}
a {
font-family: helvetica;
font-weight: bolder;
padding: 10px;
border-radius: 2px;
border: 2px solid black;
width: 100px;
text-decoration: none;
}
.btn {
color: black;
background-color: white;
}
.btn2 {
color: white;
background-color: black;
}
<div class="box">
<div class="left">
Memento
</div>
<div class="right">
Mori
</div>
</div>
Codepen: https://codepen.io/manaskhandelwal1/pen/jOMgpbd
I created a CodePen that shows how to make it work: https://codepen.io/kaireidcasey/pen/rNMXrde
The parent element needs display: flex set on it. The children each need an auto margin on one side. I am sure there are other ways to solve this, as well.
Code snippets:
HTML:
<div class="container">
<div class="divleft">
Memento
</div>
<div class="divright">
Mori
</div>
</div>
CSS:
.btn {
font-family: helvetica;
font-weight: bolder;
padding: 10px;
border-radius: 2px;
color: black;
border: 2px solid black;
background-color: white;
width: 100px;
text-decoration: none;
}
.btn2 {
font-family: helvetica;
font-weight: bolder;
padding: 10px;
border-radius: 2px;
color: white;
border: 2px solid white;
background-color: black;
width: 100px;
text-decoration: none;
}
.divleft {
margin-right: 1px;
margin-left: auto;
}
.divright {
margin-left: 1px;
margin-right: auto;
}
.container {
display: flex;
}
I am trying to make somethng like that:enter image description here
Image from the left I have done without botton-right cut, I have made border-radius.
Image from the right is what happens when you hover on whole item. AS you can see only middle is highlighted. Any idea how to fix it?
Here is my Code:
HTML:
<div class="pojemnik" onclick="location.href='nitystandardowe.html'" >
<div class="zdjecie"> <img src="img/nitystandardowe.jpg"> </div>
<div class="tekst_"><h5>Nity Standardowe</h5> </div>
</div>
CSS:
.pojemnik{
display: flex;
width: 190px;
height: 170px;
background-color: #f5f7f6;
flex-wrap: wrap;
flex-direction: column;
color: silver;
font-family: sans-serif;
text-decoration: none;
border-bottom-right-radius: 30px;
}
.pojemnik:hover {
text-decoration: none;
cursor: pointer;
width: 190px;
height: 190px;
background-position:bottom;
background-image: url("../images/icons/strzalka-w-praw-tlo.png");
background-repeat: no-repeat;
bottom: 20px;
}
.tekst_ {
border-bottom: solid 2px white;
padding-left: 10px;
}
.tekst_:hover {
border-bottom: solid 2px blue;
background-color:#00a2fa;
border-bottom: solid 1px white;
color: white;
}
.tekst_ h5{
font-family: sans-serif;
font-size: 15px;
margin-top: 5px;
margin-left: 5px;
}
.tekst_ h5:hover{
font-family: sans-serif;
font-size: 15px;
margin-top: 5px;
margin-left: 5px;
color: white;
}
.zdjecie{
align-self: flex-start;
}
.zdjecie img{
position: relative;
width: 190px;
}
You need to specify that you also need to target the .tekst_ class upon hover of .pojemnik like so:
.pojemnik:hover .tekst_ {
border-bottom: solid 2px blue;
background-color:#00a2fa;
border-bottom: solid 1px white;
color: white;
}
.pojemnik{
display: flex;
width: 190px;
height: 170px;
background-color: #f5f7f6;
/* flex-wrap: wrap; */
flex-direction: column;
color: silver;
font-family: sans-serif;
text-decoration: none;
border-bottom-right-radius: 30px;
}
.pojemnik:hover {
text-decoration: none;
cursor: pointer;
width: 190px;
height: 190px;
background-position:bottom;
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAUVBMVEX///8AAAD7+/s7OzusrKze3t7Z2dmvr6/b29tVVVUFBQVdXV34+Pjt7e0SEhKUlJRCQkLl5eXy8vJzc3NlZWXLy8tra2u9vb1KSkp5eXmZmZlkbd6rAAACfElEQVR4nO2di27aQBBFbWhSYhzCK03T///QVkhR0mAjEyBrn3vOB6C5mjs7uwvLVJWIiIiIiIiIiIiIiIiIiIjIG+1mWzqEW7LYNfU/9s+lA7kRs9f6jeVj6WBuQTuv31ndlQ7nBqzr/+BJ/FN/4r50RFdmu/qssF6Ujum6/DwSSDPqrkMhK4vLLoWoWnzoVEgy6q9uhSCJTz0KOUa971PIkdi91JCMuulViGkaL/0SKUb9wc/iCYmUWuzanOZkMaAWA4waIDHAqAESA4xq05gMARs4mwaB7FoMMCpFYrZRKU0juxYDsmgtToaApuEGjkB206BIzDYqpWlk12JAFgNqMcCoARIDjBogMcCoNo3JELCBs2kQyK7FAKNSJGYb1abRw2xsXDeLm6f9ej42fvcrPLcW29cTnzVSzsri5vjl3AQ4oxYfm9LBfolm+FvinkdXo+dhqMAT7yBGzgs8hXW9HCawLR3nBbSDFN6VDvMChi2nz6XDvIBh/z7BzyG/DvlraUA/nGwSB+9pAval/LPFNM+H515k0M/4B0pfyxzBv23DXwr3Z7BhZBB/5x1sUbzABm9RxiKTXIOMDCa3CXwG6TUI2arhfyqU3CbwAvEWZSwyyRbFZxBfg3iL0gXyT/R4gXSL8gXiLYpv9HiL4jOIr0G8RekC+Vs1xiKTXIOMDCa3CXwG6TXoly/TILlN4AXiLcpYZJItysggft7TiZldDIvy564t4BZNmH/In2HJn0PKnyXLnwfMn+nMn8vNn61eVWuyRQ+08w/6VkCBVTV7f6m6POMN76RY7A6PqvfD/u1horSbbekQRERERERERERERERERERE5Jv4CxOfKflP0w6QAAAAAElFTkSuQmCC");
background-size: 20px 20px;
background-repeat: no-repeat;
bottom: 20px;
}
.tekst_ {
border-bottom: solid 2px white;
padding-left: 10px;
}
/* .tekst_:hover {
border-bottom: solid 2px blue;
background-color:#00a2fa;
border-bottom: solid 1px white;
color: white;
} */
.pojemnik:hover .tekst_ {
border-bottom: solid 2px blue;
background-color:#00a2fa;
border-bottom: solid 1px white;
color: white;
}
.tekst_ h5{
font-family: sans-serif;
font-size: 15px;
margin-top: 5px;
margin-left: 5px;
}
/* .tekst_ h5:hover{
font-family: sans-serif;
font-size: 15px;
margin-top: 5px;
margin-left: 5px;
color: white;
} */
.zdjecie{
align-self: flex-start;
}
.zdjecie img{
position: relative;
width: 190px;
}
<div class="pojemnik" onclick="location.href='nitystandardowe.html'" >
<div class="zdjecie"> <img src="https://cdn.pixabay.com/photo/2020/11/17/15/44/cup-5752775__340.jpg"> </div>
<div class="tekst_"><h5>Nity Standardowe</h5> </div>
</div>
I have been trying to align some text inside a circle in my webpage.
So far i have been able to come up with the following:
From looking at it, it's not the best solution so I was wondering if you have any recommendation how to make sure that the text "LM" or "TM" is perfectly centered inside the circle (if that's possible).
Here is the fiddle:
Sample Demo
html:
.performance-box-container {
margin: 5px;
padding: 5px;
}
.performance-box {
width: 120px;
height: 60px;
margin: 0px 5px 5px 0px;
padding: 5px 5px 10px 5px;
border: 2px solid #868686;
background-color: rgba(202, 202, 202, 0.5);
display: inline-block;
}
.performance-box-name-in-circle {
height: 40px;
width: 40px;
border: 2px solid #000;
background-color: #fff;
border-radius: 50%;
font-weight: bold;
font-size: 12px;
display: inline-block;
}
.performance-box-name-in-circle span {
display: table-cell;
vertical-align: middle;
height: 40px;
width: 40px;
text-align: center;
padding: 0;
margin: 0;
}
.performance-box-stats {
margin-left: 5px;
font-size: 10px;
font-weight: bold;
display: inline-block;
}
.performance-box-stats p {
line-height: 1.5;
margin: 0;
}
.performance-box-stats span.positive {
color: #388C00;
}
.performance-box-stats span.unchanged {
color: #000;
}
.performance-box-stats span.negative {
color: #f00;
}
<div class="performance-box-container">
<div class="performance-box">
<div class="performance-box-name-in-circle">
<span>TM</span>
</div>
<div class="performance-box-stats">
<p>DTD: <span class="positive">+3.5%</span></p>
<p>MTD: <span class="unchanged">+0.0%</span></p>
<p>YTD: <span class="negative">-4.5%</span></p>
</div>
</div>
<div class="performance-box">
<div class="performance-box-name-in-circle">
<span>LM</span>
</div>
<div class="performance-box-stats">
<p>DTD: <span class="positive">+3.5%</span></p>
<p>MTD: <span class="unchanged">+0.0%</span></p>
<p>YTD: <span class="negative">-4.5%</span></p>
</div>
</div>
</div>
You can vertically and horizontally align them center using flexbox
display: flex;
justify-content: center;
align-items: center;
.performance-box-name-in-circle,
.performance-box-name-in-circle span {
display: flex;
justify-content: center;
align-items: center;
}
.performance-box-name-in-circle {
height: 40px;
width: 40px;
border: 2px solid #000;
background-color: #fff;
border-radius: 50%;
font-weight: bold;
font-size: 12px;
}
<div class="performance-box-name-in-circle">
<span>LM</span>
</div>
Here is the Updated JSFiddle
Used flexbox to display performance-box-name-in-circle and performance-box-stats side by side and used below css to place span in the center of the circle. Hope this helps. thanks
margin: 50%;
display: inline-block;
transform: translate(-50%, -50%);
.performance-box-container {
margin: 5px;
padding: 5px;
display: flex;
}
.performance-box {
width: 120px;
/* height: 60px; */
margin: 0px 5px 5px 0px;
padding: 5px 5px 10px 5px;
border: 2px solid #868686;
background-color: rgba(202, 202, 202, 0.5);
/* display: inline-block; */
display: flex;
justify-content: center;
align-items: center;
}
.performance-box-name-in-circle {
height: 40px;
width: 40px;
border: 2px solid #000;
background-color: #fff;
border-radius: 50%;
font-weight: bold;
font-size: 12px;
display: inline-block;
}
.performance-box-name-in-circle span {
display: table-cell;
*/
/* vertical-align: middle; */
/* height: 40px; */
/* width: 40px; */
/* text-align: center; */
padding: 0;
margin: 0;
margin: 50%;
/* margin-top: 80px; */
display: inline-block;
transform: translate(-50%, -50%);
}
.performance-box-stats {
margin-left: 5px;
font-size: 10px;
font-weight: bold;
display: inline-block;
}
.performance-box-stats p {
line-height: 1.5;
margin: 0;
}
.performance-box-stats span.positive {
color: #388C00;
}
.performance-box-stats span.unchanged {
color: #000;
}
.performance-box-stats span.negative {
color: #f00;
}
<body>
<div class="performance-box-container">
<div class="performance-box">
<div class="performance-box-name-in-circle">
<span>TM</span>
</div>
<div class="performance-box-stats">
<p>DTD: <span class="positive">+3.5%</span></p>
<p>MTD: <span class="unchanged">+0.0%</span></p>
<p>YTD: <span class="negative">-4.5%</span></p>
</div>
</div>
<div class="performance-box">
<div class="performance-box-name-in-circle">
<span>LM</span>
</div>
<div class="performance-box-stats">
<p>DTD: <span class="positive">+3.5%</span></p>
<p>MTD: <span class="unchanged">+0.0%</span></p>
<p>YTD: <span class="negative">-4.5%</span></p>
</div>
</div>
</div>
</body>
How to make this effect (cross-browsed) without using float: left?
I need to center this form so float attribute is wrong for me. Anybody can help?
I've made code as you can see below.
My code:
footer input[type=text] {
border-top: 1px solid #efefef;
border-left: 1px solid #efefef;
border-bottom: 1px solid #efefef;
border-right: 0;
width: 230px;
padding: 0 10px;
font-size: 16px;
line-height: 18px;
height: 35px;
display: inline-block;
float: left;
margin: 0 auto;
}
footer input[type=submit] {
border: 1px solid #df242b;
background: #df242b url('../../../gfx/submit.jpg') no-repeat center center;
color: #fff;
width: 38px;
height: 37px;
font-size: 18px;
line-height: 18px;
cursor: pointer;
display: inline-block;
float: left;
margin: 0 auto;
}
Because you want it cross-browser and without using float:left, you can use inline-block with vertical-align:top
And to center, you need to apply margin:0 auto to footer with some width instead
I made a few tweaks to your code.
*,
*::before,
*::after {
box-sizing: border-box
}
body {
margin: 0;
/* demo */
background: lightgreen
}
footer {
/*fix inlin block gap */
font-size: 0;
margin: 0 auto;
width: 265px; /* 230px + 35px */
}
footer input {
line-height: 18px;
height: 35px;
display: inline-block;
vertical-align: top;
}
footer input[type=text] {
border: solid #efefef;
border-width: 1px 0 1px 1px;
width: 230px;
padding: 0 10px;
font-size: 16px;
}
footer input[type=submit] {
border: 1px solid #df242b;
background: #df242b url('//dummyimage.com/35x35') no-repeat center center;
color: #fff;
width: 35px;
font-size: 18px;
cursor: pointer
}
<footer>
<input type="text">
<input type="submit">
</footer>
Your code without float:left actually works fine. Maybe you experience the line break on small sized screens. If it is the case, just add a piece of CSS for your footer like this example.
footer {
white-space: nowrap;
text-align: center;
}
footer input[type=text] {
border: 1px solid #efefef;
border-right: 0;
width: 230px;
padding: 0 10px;
font-size: 16px;
line-height: 18px;
height: 35px;
display: inline-block;
margin: 0 auto;
}
footer input[type=submit] {
border: 1px solid #df242b;
background: #df242b url('../../../gfx/submit.jpg') no-repeat center center;
color: #fff;
width: 38px;
height: 37px;
font-size: 18px;
line-height: 18px;
cursor: pointer;
display: inline-block;
margin: 0 auto;
}
<footer>
<input type="text" />
<input type="submit" />
</footer>
Use like this
<style>
body{margin:0;}
footer{
width:100%;
background:#ccc;
height:250px;
}
.form{
width:292px;
margin:0 auto;
}
footer input[type=text] {
border-top: 1px solid #efefef;
border-left: 1px solid #efefef;
border-bottom: 1px solid #efefef;
border-right: 0;
width: 230px;
padding: 0 10px;
font-size: 16px;
line-height: 18px;
height: 37px;
display: inline-block;
float: left;
margin: 0 auto;
}
footer input[type=submit] {
border: 1px solid #df242b;
background: #df242b;
color: #fff;
width: 38px;
height: 37px;
font-size: 18px;
line-height: 18px;
cursor: pointer;
display: inline-block;
float: left;
margin: 0 auto;
}
</style>
<footer>
<div class="form">
<input type="text">
<input type="submit" value=">">
</div>
</footer>