I made my text over my image correctly, but the problem is I can't figure out how to make the text in its fixed place without moving when resizing the window.
Here is my code:
img {
height: 100%;
width: 100%;
box-shadow: 0 0 10px black;
}
h1 {
font-family: 'Courier', monospace;
font-size: 1rem;
}
.container {
height: 100vh;
width: 50vh;
position: relative;
text-align: center;
}
.firstName {
position: absolute;
top: 0;
left: 3em;
}
.secName {
position: absolute;
top: 1em;
left: 5em;
color: rgb(200,0,0);
}
<div class="container">
<img src="https://i.pinimg.com/564x/ee/84/e5/ee84e597b90f4b6d827f4c73506e700d.jpg">
<div class="firstName">
<h1>Eren</h1>
</div>
<div class="secName">
<h1>Yeager</h1>
</div>
</div>
You see, when you resize the window the text pop out from the image box.
To make your text linked to the specified position on the image you may set text positioning in percentage. Here is the way that can solve it:
img {
height: 100%;
width: 100%;
box-shadow: 0 0 10px black;
}
h1 {
font-family: 'Courier', monospace;
font-size: 1rem;
}
.container {
height: 100vh;
width: 50vh;
position: relative;
text-align: center;
}
.firstName {
position: absolute;
top: 0;
left: 40%;
transform: translateX(-50%);
}
.secName {
position: absolute;
top: 1em;
left: 60%;
transform: translateX(-50%);
color: rgb(200,0,0);
}
<div class="container">
<img src="https://i.pinimg.com/564x/ee/84/e5/ee84e597b90f4b6d827f4c73506e700d.jpg">
<div class="firstName">
<h1>Eren</h1>
</div>
<div class="secName">
<h1>Yeager</h1>
</div>
</div>
Related
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>
I'm building my first actually decent website basically and I'm creating a background atm with some css and an image and I want to do it just as it is in the picture
.
(accomplished already) but it's not responsive probably because of position: absolute property and I want to make it properly responsive.
Here is the HTML code I am using for the background
.bg {
background: #9359C7;
color: white;
display: grid;
text-align: center;
height: 764px;
width: 1280px;
}
.content {
position: relative;
}
.content img {
width: auto;
height: auto;
position: absolute;
right: -178px;
bottom: 0;
}
<div class="bg">
<div class="content">
<h1>Lol</h1>
<img src="https://www.pikpng.com/pngl/m/69-698658_yami-ygi-y-gi-yu-gi-oh.png" alt="Yugi">
</div>
</div>
EDIT: I put my whole site on this patebin since idk it wouldn't let me upload it on here the snippet I was given did not work for me at least.
This should do the trick:
body {
font-family: sans-serif;
margin: 0;
padding: 0;
}
.hero {
position: relative;
overflow-x: hidden;
}
header {
position: relative;
background: black;
padding: 40px 0;
z-index: 5;
}
.content {
position: relative;
z-index: 5;
color: white;
text-align: center;
width: 70%;
height: 100vh;
max-height: 768px;
background: #9359C7;
padding: 20px;
}
img {
width: auto;
height: 98%;
position: absolute;
right: 30%;
bottom: 0;
transform: translateX(50%);
padding-top: 80px;
z-index: 10;
}
h1 {
margin: 0;
}
<div class="hero">
<header></header>
<div class="content">
<h1>Lol</h1>
</div>
<img src="https://ms.yugipedia.com//c/c4/YamiYugi-DULI.png" alt="Yugi">
</div>
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
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>
Hey I can't figure out why my divs are overlapping and what i should do...
You can watch the site here: http://hersing.dk/job/
I would like for the div carrying the hr to appear underneed the header-info div
Heres is the code from the site:
#font-face {
font-family: hersing;
src: url(lmroman10-regular.otf);
}
html,
body {
font-family: hersing;
height: 100%;
margin: 0px;
}
.container {
width: 90%;
height: 90%;
left: 5%;
top: 5%;
background: green;
position: absolute;
display: block;
clear: both;
}
.info-name {
left: 5%;
top: 10%;
position: absolute;
display: block;
}
.info-picture {
min-width: 250px;
min-height: 250px;
padding: 4px;
position: absolute;
top: 10%;
right: 5%;
background: black;
display: block;
}
.info-picture img {
height: 100%;
width: 100%;
}
#info-header {
font-size: 400%;
}
#info-title {
font-size: 150%;
font-weight: bold;
}
.header-info {
display: block;
padding: 20px;
position: relative;
width: 100%;
}
.stang-1 {
display: block;
width: 100%;
color: blue;
position: relative;
}
#hr-1 {
display: block;
height: 1px;
border: 0;
border-top: 1px solid #ccc;
margin: 1em 0;
padding: 0;
background-color: #f1a857;
}
<div class="container">
<div class="header-info">
<div class="info-name" id="info-name">
...
</div>
<div class="info-picture" id="info-picture">
<img src="images/picture.png" />
</div>
</div>
<div class="stang-1" id="stang-1">
<hr id="hr-1">
</div>
</div>
I hope someome can figure this out, cause i'm pretty lost
Both .info-name and .info-picture are absolute positioned and .header-info has no height defined.
You'd rather use relative positioning + float + clear and/or display: inline-block for both .info-* rules and everything will be fine.
<div class="container">
<div class="header-info">
<div class="info-name" id="info-name">
.....
</div>
<div class="info-picture" id="info-picture">
<img src="images/picture.png" />
</div>
</div>
<div class="stang-1" id="stang-1">
<hr id="hr-1">
</div>
</div>
<style>
#font-face {
font-family: hersing;
src: url(lmroman10-regular.otf);
}
html,
body {
font-family: hersing;
height: 100%;
margin: 0px;
}
.container {
width: 90%;
height: 90%;
left: 5%;
top: 5%;
background: green;
position: absolute;
display: block;
clear: both;
}
.info-name {
left: 5%;
top: 10%;
position: absolute;
display: block;
}
.info-picture {
width: 250px;
height: 250px;
padding: 4px;
position: relative;
top: 10%;
left:70%;
background: black;
display: block;
}
.info-picture img {
height: 100%;
width: 100%;
}
#info-header {
font-size: 400%;
}
#info-title {
font-size: 150%;
font-weight: bold;
}
.header-info {
display: block;
padding: 20px;
position: relative;
width: 100%;
}
.stang-1 {
display: block;
width: 100%;
color: blue;
position: absolute;
}
#hr-1 {
display: block;
height: 1px;
border: 0;
border-top: 1px solid #ccc;
margin: 1em 0;
padding: 0;
background-color: #f1a857;
}
</style>
I think this will solve your problem...
In this case, although very impractical, the solution would be to add a line break <br> after the .header-info div.
I repeat, this solution is not the best one by far, and you should, as pointed out in the comments by Paulie_D, change your positioning layout method.
Everything inside the absolutely positioned .container would be better positioned relative. Use css float:left; or float:right; to position elements and clear:both; when you want the next element to start below all floated elements. Use padding on the container and margins on the floated elements for positioning.
Also give .container css class of overflow:auto; to wrap around all elements inside without having to set the height every time.