I'm trying to center the icon before the block of text so that if the text contains one word or multiple lines it will always be vertically centered before the block of text.
.box {
padding: 20px;
height: auto;
width:30%;
}
.headline {
position: relative;
padding: 0 0 0 70px;
font-size: 22px;
line-height: 1.5;
margin:: 40px 0;
color: #000;
}
.headline::before {
content: '';
position: absolute;
left: 0;
top: 50%;
width: 60px;
height: 60px;
background: url('http://icons.veryicon.com/ico/Internet%20%26%20Web/Browsers%202/Google%20Chrome.ico') top right no-repeat;
background-size: cover;
}
<div class="box">
<h1 class="headline">Headline: your address is blalalaslsakdlpdslasddas/h1>
</div>
Try it this way.
.box {
padding: 20px;
height: auto;
width:30%;
}
.headline {
padding: 0 0 0 70px;
font-size: 22px;
line-height: 1.5;
margin:: 40px 0;
color: #000;
background: url('http://icons.veryicon.com/ico/Internet%20%26%20Web/Browsers%202/Google%20Chrome.ico') no-repeat;
background-size: 60px 60px;
background-position: 0 center;
}
<div class="box">
<h1 class="headline">Headline: etiam porta sem male suada magna</h1>
</div>
Use top: calc(50% - 30px); here 30 = height/2;
.box {
padding: 20px;
height: auto;
width:30%;
}
.headline {
position: relative;
padding: 0 0 0 70px;
font-size: 22px;
line-height: 1.5;
margin:: 40px 0;
color: #000;
}
.headline::before {
content: '';
position: absolute;
left: 0;
top: calc(50% - 30px);
width: 60px;
height: 60px;
background: url('http://icons.veryicon.com/ico/Internet%20%26%20Web/Browsers%202/Google%20Chrome.ico') top right no-repeat;
background-size: cover;
}
<div class="box">
<h1 class="headline">Headline: your address is blalalaslsakdlpdslasddas</h1>
</div>
Something like this are you looking for ?
.box {
padding: 20px;
height: auto;
width:30%;
}
.headline {
position: relative;
padding: 0 10px;
font-size: 22px;
line-height: 1.5;
margin: 40px 0;
color: #000;
width: 100%;
}
.headline::before {
content: '';
position: absolute;
right: 0;
margin: auto;
left: 0;
bottom: 0;
top: 0;
width: 60px;
height: 60px;
background: url(https://markwarrick.com/wp-content/uploads/2014/07/sample-icon.png) top right no-repeat;
background-size: cover;
}
<div class="box">
<h1 class="headline">Headline: your address is blalalaslsakdlpdslasddas</h1>
</div>
Related
I'm trying to make this in HTML/CSS
Image design in Figma of what I am trying to make
And currently It looks like this
Current way it looks
I am not sure why it is formatting like that and to clarify I haven't made the other 2 cards yet because I was trying to get the first 2 right.
Here is the HTMl code for it (don't mind the class names please)
<div class="v10_8">
<div class="v10_9"></div>
<div class="v10_15">
<div class="v10_14"><span class="v10_10">CAREY</span><span class="v10_11">1</span></div>
<span class="v10_12">On 56 Points</span>
</div>
</div>
<div class="v10_16">
<div class="v10_17"></div>
<div class="v10_18">
<div class="v10_19"><span class="v10_20">STANWAY</span><span class="v10_21">2</span></div>
<div class="v10_40"><span class="v10_22">On 40 Points</span><span class="v10_39">16 points behind Carey</span></div>
</div>
</div>
</div>
And here is the CSS code for it:
width: 262px;
height: 617px;
background: url("../images/v10_23.png");
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
margin: 65px;
opacity: 1;
position: relative;
top: 0px;
left: 0px;
overflow: hidden;
}
.v10_8 {
width: 262px;
height: 276px;
background: rgba(255,255,255,1);
opacity: 1;
position: relative;
top: 0px;
left: 0px;
border-top-left-radius: 44px;
border-top-right-radius: 44px;
border-bottom-left-radius: 44px;
border-bottom-right-radius: 44px;
box-shadow: -10.746728897094727px 9.851167678833008px 60px rgba(0, 0, 0, 0.09000000357627869);
overflow: hidden;
}
.v10_9 {
width: 267px;
height: 96px;
background: rgba(248,228,125,1);
opacity: 1;
position: absolute;
top: 180px;
left: 0px;
overflow: hidden;
}
.v10_15 {
width: 135px;
height: 210px;
background: url("../images/v10_15.png");
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
margin: 44px;
opacity: 1;
position: absolute;
top: 29px;
left: 65px;
overflow: hidden;
}
.v10_14 {
width: 94px;
height: 138px;
background: url("../images/v10_14.png");
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
margin: 17px;
opacity: 1;
position: absolute;
top: 0px;
left: 21px;
overflow: hidden;
}
.v10_10 {
width: 94px;
color: rgba(21,21,21,1);
position: relative;
top: 0px;
left: 0px;
font-family: Folito;
font-weight: Medium;
font-size: 29px;
opacity: 1;
text-align: left;
}
.v10_11 {
width: 30px;
color: rgba(21,21,21,1);
position: absolute;
top: 52px;
left: 32px;
font-family: Folito;
font-weight: Bold;
font-size: 71px;
opacity: 1;
text-align: left;
}
.v10_12 {
width: 135px;
color: rgba(21,21,21,1);
position: absolute;
top: 183px;
left: 0px;
font-family: Folito;
font-weight: Medium;
font-size: 22px;
opacity: 1;
text-align: left;
}
.v10_16 {
width: 262px;
height: 276px;
background: rgba(255,255,255,1);
opacity: 1;
position: absolute;
top: 341px;
left: 1px;
border-top-left-radius: 44px;
border-top-right-radius: 44px;
border-bottom-left-radius: 44px;
border-bottom-right-radius: 44px;
box-shadow: -10.746728897094727px 9.849809646606445px 60px rgba(0, 0, 0, 0.09000000357627869);
overflow: hidden;
}
.v10_17 {
width: 267px;
height: 96px;
background: rgba(119,221,119,1);
opacity: 1;
position: absolute;
top: 180px;
left: 0px;
overflow: hidden;
}
.v10_18 {
width: 167px;
height: 241px;
background: url("../images/v10_18.png");
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
margin: 44px;
opacity: 1;
position: absolute;
top: 16px;
left: 50px;
overflow: hidden;
}
.v10_19 {
width: 135px;
height: 138px;
background: url("../images/v10_19.png");
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
margin: 17px;
opacity: 1;
position: absolute;
top: 0px;
left: 16px;
overflow: hidden;
}
.v10_20 {
width: 135px;
color: rgba(21,21,21,1);
position: absolute;
top: 0px;
left: 0px;
font-family: Folito;
font-weight: Medium;
font-size: 29px;
opacity: 1;
text-align: left;
}
.v10_21 {
width: 42px;
color: rgba(21,21,21,1);
position: absolute;
top: 52px;
left: 46px;
font-family: Folito;
font-weight: Bold;
font-size: 71px;
opacity: 1;
text-align: left;
}
.v10_40 {
width: 167px;
height: 57px;
background: url("../images/v10_40.png");
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
margin: 11px;
opacity: 1;
position: absolute;
top: 183px;
left: 0px;
overflow: hidden;
}
.v10_22 {
width: 137px;
color: rgba(21,21,21,1);
position: absolute;
top: 0px;
left: 15px;
font-family: Folito;
font-weight: Medium;
font-size: 22px;
opacity: 1;
text-align: left;
}
.v10_39 {
width: 167px;
color: rgba(21,21,21,1);
position: absolute;
top: 38px;
left: 0px;
font-family: Folito;
font-weight: Medium;
font-size: 16px;
opacity: 1;
text-align: left;
}
I understand the design may look slightly hard to code but I will try.
I would appreciate it if someone can help me thanks.
Two problems here...
FIRST ONE: The first code of the css you provided is incomplete.
FIRST ONE:
As I looked through your code, I realised you interchanged the positioning of the elements. Use the absolute position on the parent element and relative on the contents of the parent element. If you are a bit confused about the second issue, kindly correct the first mistake and prompt me. I'll help you out.
For this design, you must have a box that contains three columns and have two contents in the left column and the contents in the other columns are in the center.
You can achieve this in minimum div this is example for your single card you can make further changes in it.
.box1_1 {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 262px;
height: 276px;
background: gray;
opacity: 1;
border-radius: 44px;
box-shadow: -10.746728897094727px 9.851167678833008px 60px rgba(0, 0, 0, 0.09000000357627869);
overflow: hidden;
position: relative;
}
.box1_3 {
padding-top: 20%;
font-size: 25px;
font-weight: bold;
text-align: center;
background: red;
height: 100%;
width: 100%;
position: absolute;
top: 10;
}
.box1_2{
font-size: 25px;
font-weight: bold;
text-align: center;
background: yellow;
height: 35%;
width: 100%;
position: absolute;
bottom: 0%;
box-shadow: -10.746728897094727px 9.851167678833008px 60px rgba(0, 0, 0, 0.09000000357627869); /* Add the same box-shadow as the parent container */
}
<div class="box1_1">
<div class="box1_3">
<p>CAREY</p>
<p>1</p>
</div>
<div class="box1_2">
<p>On 56 Points</p>
</div>
</div>
My header is devided in 3 sections: left, center and right. The left section is empty. In the center section I have my page title and in the right section I placed an "Account" link with an icon next to it. The link contains the word ACCOUNT and an icon. the icon is somehow pushed to the top and leaves a blank space below it next to the word. I want them both in one line and on the same hight. How can I achieve this? I added a red background to make the problem better understandable.
html {
height: 100%;
box-sizing: border-box;
overflow: hidden;
}
*,
*:before,
*:after {
box-sizing: inherit;
overflow: inherit;
}
body {
background-color: #f5f5f5;
margin: 0;
padding: 0;
position: relative;
height: 100%;
}
#in {
width: 1000px;
margin-left: auto;
margin-right: auto;
height: 100%;
}
/* ------------------------------------------------------------------------ */
/* -------------------------------- HEADER -------------------------------- */
/* ------------------------------------------------------------------------ */
header {
background-color: #131b23;
border-bottom: 6px solid #0f151a;
text-align: center;
left: 0;
top: 0;
width: 100%;
height: 170px;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
z-index: 99;
}
#left {
background-color: green;
width: 20%;
position: absolute;
height: 164px;
}
#center {
background-color: red;
width: 60%;
margin-left: auto;
margin-right: auto;
height: 100%;
position: absolute;
left: 20%;
right: 20%;
height: 164px;
}
#right {
background-color: blue;
width: 20%;
height: 100%;
position: absolute;
right: 0;
height: 164px;
}
#heading {
font-size: 60px;
display: block;
margin-bottom: -7px;
margin-top: 15px;
}
.accountlink {
font-family: "Helvetica";
text-decoration: none;
font-weight: 800;
color: #ffffff;
font-size: 13px;
letter-spacing: 1px;
text-transform: uppercase;
background-color: red;
position: absolute;
right: 30px;
top: 15px;
}
.navigationicon {
position: relative;
width: 24px;
margin: 0;
padding: 0;
top: 50%;
bottom: 50%;
}
<header>
<div id="left">
</div>
<div id="center">
<h1 id="heading">My Page</h1>
</div>
<div id="right">
<a class="accountlink" href="login.html">Account <img class="navigationicon" src="https://cdn2.iconfinder.com/data/icons/ios-7-icons/50/user_male2-512.png"></a>
</div>
</header>
Can you check this ?
html {
height: 100%;
box-sizing: border-box;
overflow: hidden;
}
*,
*:before,
*:after {
box-sizing: inherit;
overflow: inherit;
}
body {
background-color: #f5f5f5;
margin: 0;
padding: 0;
position: relative;
height: 100%;
}
#in {
width: 1000px;
margin-left: auto;
margin-right: auto;
height: 100%;
}
/* ------------------------------------------------------------------------ */
/* -------------------------------- HEADER -------------------------------- */
/* ------------------------------------------------------------------------ */
header {
background-color: #131b23;
border-bottom: 6px solid #0f151a;
text-align: center;
left: 0;
top: 0;
width: 100%;
height: 170px;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
z-index: 99;
}
#left {
background-color: green;
width: 20%;
position: absolute;
height: 164px;
}
#center {
background-color: red;
width: 60%;
margin-left: auto;
margin-right: auto;
height: 100%;
position: absolute;
left: 20%;
right: 25%;
height: 164px;
}
#right {
background-color: blue;
width: 20%;
height: 100%;
position: absolute;
right: 0;
height: 164px;
}
#heading {
font-size: 60px;
display: block;
margin-bottom: -7px;
margin-top: 15px;
}
.accountlink {
font-family: "Helvetica";
text-decoration: none;
font-weight: 800;
color: #ffffff;
font-size: 13px;
letter-spacing: 1px;
text-transform: uppercase;
background-color: white;
position: absolute;
left: 50px;
top: 20px;
background: url("https://cdn2.iconfinder.com/data/icons/ios-7-icons/50/user_male2-512.png");
background-size: 24px;
background-repeat: no-repeat;
background-position-x: right;
background-position-y: 0px;
width: 40%;
line-height: 2;
}
<header>
<div id="left">
</div>
<div id="center">
<h1 id="heading">My Page</h1>
</div>
<div id="right">
<a class="accountlink" href="login.html">Account </a>
</div>
</header>
Four changes to your css code to get there: 2 at .navigationicon and 2 at .accountlink
.accountlink {
font-family: "Helvetica";
text-decoration: none;
font-weight: 800;
color: #ffffff;
font-size: 13px;
letter-spacing: 1px;
text-transform: uppercase;
background-color: red;
position: absolute;
right: 80px;
top: 70px;
}
.navigationicon {
position: relative;
width: 12px;
margin: 0 0 2px -5px;
padding: 0;
top: 50%;
bottom: 50%;
}
I have small problem with make a two horizontal backgrounds in one div with border radius. I want the main div was a circle.
My code
body{
text-align: center;
}
.split-outer {
position: relative;
display: inline-block;
width: 200px;
height: 200px;
z-index: 2;
background: #014495;
border-radius: 100%;
}
.split-outer::after{
content: "";
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 50%;
z-index: -1;
background: #fff;
border-bottom-right-radius: 200px;
border-bottom-left-radius: 200px;
}
.split-inner{
width: 200px;
height: 200px;
margin: 0 auto;
color: #fff;
text-align: center;
}
span{
display: block;
}
span.split-title{
padding: 30px 0 10px 0;
font-size: 55px;
text-align: center;
line-height: 55px;
}
span.split-content{
padding: 20px 0;
font-size:18px;
color: #014495;
}
<div class="container-fliud">
<div class="jumbotron">
<div class="split-outer">
<div class="split-inner">
<span class="split-title">100</span>
<span class="split-content">Lorem ipsum</span>
<button type="button" class="btn btn-primary btn-sm">Button</button>
</div>
</div>
</div>
</div>
But i have a small bug, in the after element i see some blue backround line from the first div. It looks like a border line genrated from the radius. But i wannt a clean white round background.
Codepen prev :http://codepen.io/michal_t/pen/KdoZYz/
Put border: 2px solid white in :after.
Here is css code:
body {
text-align: center;
}
.split-outer {
position: relative;
display: inline-block;
width: 200px;
height: 200px;
z-index: 2;
background: #014495;
border-radius: 100%;
}
.split-outer::after {
content: "";
position: absolute;
left: -2px;
bottom: -1px;
width: 100%;
height: 50%;
z-index: -1;
background: #fff;
border-bottom-right-radius: 200px;
border-bottom-left-radius: 200px;
border: 2px solid white;
}
.split-inner {
width: 200px;
height: 200px;
margin: 0 auto;
color: #fff;
text-align: center;
}
span {
display: block;
}
span.split-title {
padding: 30px 0 10px 0;
font-size: 55px;
text-align: center;
line-height: 55px;
}
span.split-content {
padding: 20px 0;
font-size: 18px;
color: #014495;
}
Here is fiddle.
You could create the top half of the background by removing the background color from .split-outer and then using a :before pseudo, similar to how the bottom half is created with an :after pseudo.
.split-outer:before {
content: "";
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 50%;
z-index: -1;
background: #014495;
background-image: initial;
background-position-x: initial;
background-position-y: initial;
background-size: initial;
background-repeat-x: initial;
background-repeat-y: initial;
background-attachment: initial;
background-origin: initial;
background-clip: initial;
background-color: #014495;
border-top-right-radius: 200px;
border-top-left-radius: 200px;
}
http://codepen.io/anon/pen/dYmdva
How to align the raccoon picture so it appear at the right bottom of the big round picture? As it is at the image.
I tried background-position: bottom right; as well as position: absolute; but it doesn't work.
See the code below.
Thank You.
.p-i--1 {
background-image: url(http://www.zerohedge.com/sites/default/files/pictures/picture-3930.jpg);
}
.p-i {
border-radius: 50%;
background-position: bottom right;
width: 40px;
height: 40px;
position: absolute;
}
.p-1 {
float: left;
width: 220px;
height: 100%;
position: relative;
}
.p-wrap {
bottom: 0;
width: 100%;
text-align: center;
}
.pic-wrap {
width: 122px;
height: 122px;
margin: 0 auto;
}
.p_pic-1 {
background-image: url(http://www.fernomortuary.com/~/media/products-mortuary/swatches/Swatch_Burgundy.ashx?w=122);
background-position: center;
float: left;
width: 122px;
height: 122px;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
}
.p-description {
font-family: Roboto;
font-weight: 300;
color: #666;
font-size: 14px;
text-align: center;
float: left;
margin-top: 0;
}
.p-name {
text-align: center;
}
<div class="p-1">
<div class="p-i--1 p-i"></div>
<div class="pic-wrap">
<a class="p_pic-1" href="index.html"></a>
</div>
<div class="p_wrap">
<h4 class="p-name">Some text</h4>
<p class="p-description">Some very very very very long description</p>
</div>
</div>
Put the smaller picture within .pic-wrap. Give it an absolute position and align it using bottom and right properties:
JS Fiddle
CSS Changes made:
.pic-wrap {
position: relative;
}
.p-i {
position: absolute;
bottom: 0;
right: 0;
}
And if you want the white border around the small image:
.p-i {
border: 3px solid white;
}
JS Fiddle
Just add a bottom and right property to your absolute element like this:
.p-i {
border-radius: 50%;
background-position: bottom right;
width: 40px;
height: 40px;
position: absolute;
bottom: 100px;
right: 50px;
}
Here's a snippet with the above codes:
.p-i--1 {
background-image: url(http://www.zerohedge.com/sites/default/files/pictures/picture-3930.jpg);
}
.p-i {
border-radius: 50%;
background-position: bottom right;
width: 40px;
height: 40px;
position: absolute;
bottom: 100px;
right: 50px;
}
.p-1 {
float: left;
width: 220px;
height: 100%;
position: relative;
}
.p-wrap {
bottom: 0;
width: 100%;
text-align: center;
}
.pic-wrap {
width: 122px;
height: 122px;
margin: 0 auto;
}
.p_pic-1 {
background-image: url(http://www.fernomortuary.com/~/media/products-mortuary/swatches/Swatch_Burgundy.ashx?w=122);
background-position: center;
float: left;
width: 122px;
height: 122px;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
}
.p-description {
font-family: Roboto;
font-weight: 300;
color: #666;
font-size: 14px;
text-align: center;
float: left;
margin-top: 0;
}
.p-name {
text-align: center;
}
<div class="p-1">
<div class="p-i--1 p-i"></div>
<div class="pic-wrap">
<a class="p_pic-1" href="index.html"></a>
</div>
<div class="p_wrap">
<h4 class="p-name">Some text</h4>
<p class="p-description">Some very very very very long description</p>
</div>
</div>
Here is a fiddle: https://jsfiddle.net/6sxLj3hL/
Your hard coded height on the container wasn't necessary so I removed it.
.p-i--1 {
background-image: url(http://www.zerohedge.com/sites/default/files/pictures/picture-3930.jpg);
}
.p-i {
border-radius: 50%;
background-position: bottom right;
width: 40px;
height: 40px;
float:right
}
.p-1 {
float: left;
width: 220px;
height: 100%;
position: relative;
}
.p-wrap {
bottom: 0;
width: 100%;
text-align: center;
}
.pic-wrap {
width: 122px;
margin: 0 auto;
overflow: auto;
}
.p_pic-1 {
background-image: url(http://www.fernomortuary.com/~/media/products-mortuary/swatches/Swatch_Burgundy.ashx?w=122);
background-position: center;
width: 122px;
height: 122px;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
display: block;
overflow: auto;
}
.p-description {
font-family: Roboto;
font-weight: 300;
color: #666;
font-size: 14px;
text-align: center;
float: left;
margin-top: 0;
}
.p-name {
text-align: center;
}
I rearranged your HTML a bit
<div class="p-1">
<div class="pic-wrap">
<a class="p_pic-1" href="index.html"></a>
<div class="p-i--1 p-i"></div>
</div>
<div class="p_wrap">
<h4 class="p-name">Some text</h4>
<p class="p-description">
Some very very very very long description
</p>
</div>
</div>
I have two DIVs inside another two parent DIVs. What I am looking to do is align the "clocks" DIV to the left of the "panel" DIV and the "sd" DIV toward the center of the "panel" DIV.
What is showing up as now:
What I am looking to do:
My HTML looks like:
<div id="weather">
<div id="panel">
<div class="clocks">
</div>
<div id="sd">
<script type="text/javascript" src="http://www.weathers.com"></script>
</div>
</div>
<p class="slide">Weather</p>
</div>
My CSS looks like:
#weather {
margin: 0 auto;
padding: 0;
width: 990px;
font: 75%/120% Arial, Helvetica, sans-serif;
top: 0;
position: absolute;
z-index: 999999999;
left: 0%;
margin-left: 0px;
}
#panel {
background: url('weatherBack.png') no-repeat;
height: 195px;
width: 990px;
display: none;
text-align: center;
margin: 0 auto;
line-height: 195px;
}
#sd {
margin: 0 auto;
padding: 0;
width: 175px;
}
.slide {
margin: 0;
padding: 0;
border-top: solid 4px #422410;
background: url(btn.png) no-repeat center top;
}
.btn-slide {
background: url(white-arrow.gif) no-repeat right -50px;
text-align: center;
width: 144px;
height: 31px;
padding: 10px 10px 0 0;
margin: 0 auto;
display: block;
font: bold 120%/100% Arial, Helvetica, sans-serif;
color: #fff;
text-decoration: none;
}
.active {
background-position: right 12px;
}
.learn {
z-index: 9999999999999;
position: absolute;
top: 85px;
right: 3px;
}
.box-cnt {
padding: 10px;
padding-bottom: 2px;
background-color: #1FAAEB;
zoom: 1;
filter: alpha(opacity=80);
opacity: 0.8;
}
.clocks {
width: 209px;
height: 131px;
position: relative;
top: 0;
left: 151;
background: url('css/images/clockbg.png') no-repeat 0 0;
}
Try the float property with a value of left on your clock and weather panels:
.clocks {
width: 209px;
height: 131px;
position: relative;
float: left;
background: url('css/images/clockbg.png') no-repeat 0 0;
}
#sd {
margin: 0 auto;
padding: 0;
width: 175px;
position: relative;
float: left;
}
Here is a working JSFiddle link: http://jsfiddle.net/cYFfT/
If you want to have more space between them, simply set a left margin on the SD panel,
as in this update: http://jsfiddle.net/cYFfT/1/