How do I correctly fromat this div's contents? - html

I'm trying to improve my basic design "skills". I'm attempting to recreate this:
but I don't know how to format it correctly with the right css.
.container {
width: 40%;
height: 107px;
background: #fff;
position: relative;
}
.cover {
position: absolute;
left: 10px;
top: 5px;
}
.icon {
position: absolute;
right: 10px;
bottom: 10px;
}
#container h3, p {
color: #000;
position: absolute;
left: 60px;
top: 15px;
margin: 5px;
}
<div class="container">
<img class="cover" src="book.png" width="45" height="60"/>
<h3>Title of Something</h3>
<p> Cracking the code </p>
<img class="icon" src="icon.png" width="45" height="40"/>
</div>
Any suggestions?

Here is the way to fix the issue, your html working fine
only the css need to be edit.
CSS
.container {
width: 40%;
height: 107px;
background: #fff;
position: relative;
float:left
}
.cover {
position: absolute;
left: 10px;
top: 5px;
}
.icon {
position: absolute;
right: 10px;
bottom: 10px;
top: 15px
}
h3, p {
color: #000;
position: relative;
left: 60px;
top: 15px;
margin: 5px;
}
DEMO

here is a very simple solution: http://codepen.io/elstermann/pen/oXRVxG
HTML
<header>
<img id=img-book alt=book src=http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png width=158 height=158>
<div id=title>
<h3>Title of Something</h3>
<p id=h1-sub>Title of Something</p>
</div>
<img id=img-face alt=book src=http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png width=158 height=158>
</header
CSS
header {
margin: 0 auto;
max-width: 950px;
min-width: 500px;
width: 90%;
}
#img-book, #title {
float: left;
}
#img-face {
float: right;
}

Related

placing a circle on a picture I have in my css

I'm trying to put a circle on the corner of a frame like the picture but only the part of the circle that's inside of the frame can be seen. The part that i marked with x is invisible.
How it looks:
How I want it to look:
My code:
.circle{
height: 150px;
width: 150px;
border-radius: 50%;
background: black;
line-height: 0;
position: absolute;
right:-20px; top:-2px;
z-index: 2;
}
.circle:after {
content: "";
display: block;
padding-bottom: 100%;
position: relative;
}
.circle-txt {
/* (E1) CENTER TEXT IN CIRCLE */
position: absolute;
bottom: 50%;
width: 100%;
text-align: center;
/* (E2) THE FONT - NOT REALLY IMPORTANT */
font-family: "font";
font-size:inherit;
}
:root{
--pic:"M510.295 108.139C571.169 177.774 609.697 279.36 589.662 365.38C570.398 451.399 492.572 521.854 409.352 555.443C326.132 589.031 236.748 586.574 162.775 548.889C88.8013 511.204 30.2391 438.292 8.66355 353.91C-12.1414 268.71 4.81077 171.22 56.438 104.043C107.295 36.8656 193.597 0 278.358 0C363.89 0.819237 448.651 38.5041 510.295 108.139Z"
}
.frame{
padding-right: 1px;
height: 579px;
width: 595px;
clip-path: path(var(--pic));
margin-left: 8%;
margin-bottom: 5%;
position: relative;
z-index: 1;
}
img{
height: 579px;
width: 595px;
}
<div class="frame">
<img src="1.png">
<div class="circle">
<div class="circle-txt">فریلنسینگ چیست؟</div>
</div>
</div>
I would appreciate if anyone can tell me what is that I'm doing wrong.
Check out my solution.
.circle {
height: 150px;
width: 150px;
border-radius: 50%;
background: black;
line-height: 0;
position: absolute;
right: 30px;
top: 38px;
z-index: 2;
}
.wrapp {
height: 579px;
width: 595px;
margin-left: 8%;
margin-bottom: 5%;
position: relative;
}
.frame {
clip-path: path(var(--pic));
}
img {
height: 579px;
width: 595px;
background: red;
}
.circle:after {
content: "";
display: block;
padding-bottom: 100%;
position: relative;
}
.circle-txt {
/* (E1) CENTER TEXT IN CIRCLE */
position: absolute;
bottom: 50%;
width: 100%;
text-align: center;
color:#fff;
/* (E2) THE FONT - NOT REALLY IMPORTANT */
font-family: "font";
font-size:inherit;
}
:root{
--pic:"M510.295 108.139C571.169 177.774 609.697 279.36 589.662 365.38C570.398 451.399 492.572 521.854 409.352 555.443C326.132 589.031 236.748 586.574 162.775 548.889C88.8013 511.204 30.2391 438.292 8.66355 353.91C-12.1414 268.71 4.81077 171.22 56.438 104.043C107.295 36.8656 193.597 0 278.358 0C363.89 0.819237 448.651 38.5041 510.295 108.139Z"
}
<div class="wrapp">
<div class="circle">
<div class="circle-txt">فریلنسینگ چیست؟</div>
</div>
<div class="frame">
<img src="1.png" />
</div>
</div>
From your description and images shared, it seems you maybe using border-radius around the entire set of elements, which is cutting off the smaller top right hand side circle.
Here is a solution you can use.
HTML:
<div class="circle-wrapper">
<div class="big-circle"></div>
<div class="little-circle"></div>
<div class="circle-wrapper">
CSS:
.circle-wrapper { position: relative; width: 24px; height: 24px; }
.big-circle { width: 24px; height: 24px; background: red; border-radius: 24px; }
.little-circle { position: absolute; width: 12px; height: 12px; background: blue; border-radius: 12px; top: -6px; right: -6px; }
Use border-radius to allow overflowing content to be seen, clip-path cuts it out ;) (or use it on img itself if that's good enough)
possible example.
.circle{
height: 150px;
width: 150px;
border-radius: 50%;
background: black;
line-height: 0;
position: absolute;
right:-20px; top:-2px;
z-index: 2;
}
.circle:after {
content: "";
display: block;
padding-bottom: 100%;
position: relative;
}
.circle-txt {
/* (E1) CENTER TEXT IN CIRCLE */
position: absolute;
bottom: 50%;
width: 100%;
text-align: center;
/* (E2) THE FONT - NOT REALLY IMPORTANT */
font-family: "font";
font-size:inherit;
color:hotpink;
}
:root{
--pic:"M510.295 108.139C571.169 177.774 609.697 279.36 589.662 365.38C570.398 451.399 492.572 521.854 409.352 555.443C326.132 589.031 236.748 586.574 162.775 548.889C88.8013 511.204 30.2391 438.292 8.66355 353.91C-12.1414 268.71 4.81077 171.22 56.438 104.043C107.295 36.8656 193.597 0 278.358 0C363.89 0.819237 448.651 38.5041 510.295 108.139Z"
}
.frame{
padding-right: 1px;
height: 579px;
width: 595px;
/*clip-path: path(var(--pic));*/
margin-left: 8%;
margin-bottom: 5%;
position: relative;
z-index: 1;
border-radius:50%;
border:solid;
}
img{
height: 579px;
width: 595px;
border-radius:50%;
background:hotpink;
}
<div class="frame">
<img src="1.png">
<div class="circle">
<div class="circle-txt"> فریلنسینگ چیست؟ </div>
</div>
</div>

With CSS, Position a div (B) below (vertically, not z-index) another div (A) based on div A's height and position

Consider the following jsfiddle:
https://jsfiddle.net/0fwhmhLe/
html markup:
<div class="city-losangeles-bg">
<div class="user-container user-container-losangeles">
<div class="user-pic user-pic-losangeles"></div>
<div class="user-name-container">
<p class="user-name">User Name</p>
<div class="user-name-mask"></div>
</div>
<hr class="underline">
<div class="ellipse-container">
<div class="ellipse ellipse-losangeles-1"></div>
<div class="ellipse ellipse-losangeles-2 ellipse-with-left-margin"></div>
<div class="ellipse ellipse-losangeles-3 ellipse-with-left-margin"></div>
</div>
</div>
<p class="user-text user-text-losangeles">Some text that needs to be below the user-container div, based on the position and height of user-container</p>
</div>
css:
.city-losangeles-bg
{
width: 100%;
height: 1230px;
top: 0px;
background-color: orange;
position: relative;
}
.user-container
{
position: relative;
width: 206px;
height: 192px;
background-color: green;
}
.user-container-losangeles
{
left: 41%;
top: 25px;
}
.user-pic
{
position: relative;
width: 73px;
height: 73px;
left: -36.5px;
margin-left: 50%;
border-radius: 50%;
border: none;
}
.user-pic-losangeles
{
background-color: red;
}
.user-name-mask
{
position: relative;
width: inherit;
height: inherit;
top: 0;
}
.user-name
{
position: relative;
font-family: Ariel;
font-size: 28px;
text-align: center;
width: 100%;
/*top: -6px;*/ /*so text hides properly under color bar reveal animation */
}
.underline
{
position: absolute;
width: 178px;
top: 138px;
left: 14px;
margin-top: 0;
margin-bottom: 0;
}
.ellipse-container
{
position: absolute;
width: 126px;
height: 30px;
top: 162px;
left: 40px;
}
.ellipse
{
position: relative;
width: 30px;
height: 30px;
float: left;
border-radius: 50%;
border: none;
}
.ellipse-with-left-margin
{
margin-left: 18px;
}
.ellipse-losangeles-1
{
background-color: #4574b4;
}
.ellipse-losangeles-2
{
background-color: #71c8ca;
}
.ellipse-losangeles-3
{
background-color: #e6dddd;
}
.user-text
{
position: relative;
margin-top: 0; /* 100 */
font-family: Ariel;
font-size: 26px;
text-align: center;
line-height: 50px;
color: #848484;
}
.user-text-losangeles
{
margin-left: 29%;
width: 50%;
}
I can't figure out how to make the paragraph tag user-text user-text-losangeles always be below the div user-container user-container-losangeles. I thought they should automatically stack and if I changed user-container-losangeles's top property that user-text-losangeles would get bumped down as well.
Someone tell me what obvious mistake I am making please!!
You can use padding-top: 25px; on the container (.city-losangeles-bg) instead of the top:25px; of .user-container-losangeles
https://jsfiddle.net/y8pocwsn/1/
The reason: With position:relative and a topsetting an element is simply moved down from its original position, but the subsequent elements are NOT moved. The space reserved for the element is still the space it would occupy with top: 0 , which is the same as if that element would have position: static

Absolute element not placing over relative element

Within my header, I am trying to place pending-button-notification over theimages-cart image. For some reason, the pending-button-notification div is showing on the left side of the header div.
Does anyone see why this isn't placing correctly?
This is the problematic code:
<div id="pending-order-button">
<a href="pendingOrders.html"><img src="images/cart.png" class="header-buttons" alt="Car">
<div id="pending-button-notification"></div>
</a>
</div>
header {
width: 100%;
max-width: 100%;
height: 100px;
position: relative;
border-bottom: 1px solid #E5E5E5;
}
#header-wrap {
width: 90%;
height: 100%;
margin: auto 5%;
}
#header-logo {
width: 200px;
height: auto;
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.header-buttons {
width: 30px;
height: auto;
float: right;
margin: 30px 40px 0 50px;
cursor: pointer;
}
.header-buttons:first-child {
margin-right: 0;
}
#pending-order-button {
position: relative;
}
#pending-button-notification {
border-radius: 15px;
background: #09afdf;
height: 25px;
width: 25px;
position: absolute;
color: #FFF;
font-size: 1.3rem;
top: 5px;
left: 5px;
text-align: center;
}
<header>
<div id="header-wrap">
Logo
<img src="images/menu.png" class="header-buttons" alt="Pending Orders">
<div id="pending-order-button">
<a href="pendingOrders.html"><img src="images/cart.png" class="header-buttons" alt="Car">
<div id="pending-button-notification"></div>
</a>
</div>
</div>
</header>
It's your float:right on .header-buttons which is causing the problem.
I suggest that you remove that and float the #pending-order-button div instead so that it and all it's content is moved to the right.
#pending-order-button {
position: relative;
float:right;
}

H1 tag border length possible? [duplicate]

This question already has answers here:
Title with bottom border smaller than width
(7 answers)
Closed 7 years ago.
I made myself a full width-image to where i added text.
I've been scratching my head for a great amount of time now.
I'm trying to find the best solution for adding text with borders both above and below.
However, i would like the borders to be at half the length or less but i simply can't figure it out.
Before the Tag-class i tried using borders on the text-container div but i had problems with centering the text and getting the right alignment.
Here's how it is right now:
CSS:
.adcontainer {
position: relative;
width: 100%;
height: auto;
}
.adcontainer img {
width: 100%;
height: auto;
}
.adcontainertext {
position: absolute;
top: 25%;
left: 15%;
z-index: 0;
padding: 0;
padding: 1.2em;
font-size: .5em;
text-align: center;
}
.advertheading
{
font-size: 20px;
border-bottom: 1px solid white;
border-top: 1px solid white;
line-height: 100px;
display:inline-block
}
HTML:
<div style="clear: both;">
<div class="adcontainer"><img src="https://cdn.shopify.com/s/files/1/0786/5107/files/LARGE_BANNER-BELOW.jpg?5938182738858039286" />
<div class="adcontainertext">
<h2 class="advertheading" style="font-weight: normal; color: #ffffff;">Join the club</h2>
</div>
</div>
</div>
Best Regards,
Robbin.
.adcontainer {
position: relative;
width: 100%;
height: auto;
}
.adcontainer img {
width: 100%;
height: auto;
}
.adcontainertext {
position: absolute;
top: 25%;
left: 15%;
z-index: 0;
padding: 0;
padding: 1.2em;
font-size: .5em;
text-align: center;
}
.adcontainertext h2:before {
content: '';
border-top: 1px solid #FFF;
position: absolute;
width: 50%;
left: 25%;
top: 0;
}
.advertheading {
font-size: 20px;
line-height: 100px;
display:inline-block;
position: relative;
}
.adcontainertext h2:after {
content: '';
border-bottom: 1px solid #FFF;
position: absolute;
width: 50%;
left: 25%;
bottom: 0;
}
<div style="clear: both;">
<div class="adcontainer">
<img src="https://cdn.shopify.com/s/files/1/0786/5107/files/LARGE_BANNER-BELOW.jpg?5938182738858039286" />
<div class="adcontainertext">
<h2 class="advertheading" style="font-weight: normal; color: #ffffff;">Join the club</h2>
</div>
</div>
</div>

html & css - positioning divs at exact coordinates

i'm trying to recreate this image in pure html and css, or add a little javascript if nessascary:
and here's what i have so far:
i'm trying to move that small orange box near the center up to match the blue line, but she won't budge
.middletop {
position: absolute;
background-color: #fe9800;
width: 26px;
height: 16px;
left: 471px;
}
and here's the entire code:
layout.html
<html>
<head>
<title>LCARS</title>
<link rel="stylesheet" href="static/style.css"/>
</head>
<body>
<div class="topleft">
</div>
<div class="topleft2">
</div>
<div class="middletop">
</div>
<div class="bottomleft">
</div>
<div class="bottomleft2">
</div>
<div class="bottomleft3">
</div>
<div class="bottomleft4">
</div>
<div class="content">
</div>
<div class="content2">
</div>
</body>
<footer>
</footer>
</html>
style.css
body {
background-color: black;
}
.topleft {
background-color: #c498c4;
width: 126px;
height: 90px;
}
.topleft2 {
margin-top: 5px;
background-color: #9b98fe;
width: 463px;
height: 112px;
border-radius: 0 0 0 70px;
}
.bottomleft {
margin-top: 7px;
background-color: #cc6061;
width: 463px;
height: 91px;
border-radius: 70px 0 0 0;
}
.bottomleft2 {
margin-top: 5px;
background-color: #cc6061;
width: 126px;
height: 137px;
}
.bottomleft3 {
margin-top: 5px;
background-color: #fe9800;
width: 126px;
height: 38px;
}
.bottomleft4 {
margin-top: 5px;
background-color: #ffa873;
width: 126px;
height: 180px;
}
.middletop {
position: absolute;
background-color: #fe9800;
width: 26px;
height: 16px;
left: 471px;
}
.content {
background-color: /*#6D6A6A*/black;
position: absolute;
left: 127px;
top: 239px;
border-radius: 35px;
width: 900px;
height: 700px;
}
.content2 {
background-color: black;
position: absolute;
left: 127px;
top: -2;
border-radius: 0 0 0 35px;
width: 900px;
height: 200px;
}
While I advise having a look into using absolute positioning extensively, if you're already doing it and you're happy with it, you just have to set top and you should be good to go:
.middletop {
position: absolute;
background-color: #fe9800;
width: 26px;
height: 16px;
left: 476px;
top:199px /* <-- this is what I added */
}
Here is a demo.
Try using
position: absolute;
top: /*the amount of px from the top to your wanted location*/;
left: /*the amount of px from the left to your wanted location*/;
z-index:1000; /*<= this is to be above all other elements*/
Use the css top:100px;. And to see it use: z-index:100;