I have this problem with my css, I'm trying to make my X button appear to the top right corner of my the div frame. The problem is that it is just not appearing anywhere. the codes seems okay to me. I wonder what is causing this problem?. Can someone help? Please run the snippet you will see that the button x is not appearing at all!and I apologize for the unnecessary long html codes.
.x {
position: absolute;
background: red;
color: white;
top: -10%;
right: -10%;
}
<div class="divider"></div>
<div class="frame" onmouseover=""><button class="x">X</button><!--This button-->
<div class="section">
<h5>Only take into consideration of the x button</h5>
<center>
<div class="uploader" onclick="selectFile(this)"></div><input type="file" name="userprofile_picture" accept="image/*" onchange="handleImage(this)" /></center>
<div class="grid-container">
<div class="grid-item">
<p style="color:white">A) '+A+'</p>
</div>
<div class="grid-item">
<p style="color:white">B) '+C+'</p>
</div>
<div class="grid-item">
<p style="color:white">C) '+B+'</p>
</div>
<div class="grid-item">
<p style="color:white">D) '+D+'</p>
</div>
</div>
<div class="grid-container3">
<div class="grid-item"><span style="color:green;font-weight:bold">Answer: '+answer+'</span></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item"><input class="timer" type="range" min="3" max="20" value="10" oninput="showValue(this)">
<h4>
<p>5 Minutes</p>
</h4>
</div>
</div>
</div>
</div><br>
Your values are wrong. You're placing it on the top right corner and outside of the frame because of the negative values. Try this:
.x {
position: absolute;
background: red;
color: white;
top: 10%;
right: 10%;
}
There is a problem with your positioning
The absolute position makes it to the top right-hand corner, from right to left. By making it -10% you are taking it off the screen. You could position it with a positive number
Without positioning
Related
This is my code and a screenshot of the website.
How can I align my text "button will show a page as below" on the left but on the same height like the start of my picture?
<div class="col-sm-9">
<div class="well">
<h4>Item Price</h4>
<span class="align-baseline";><img src="https://picsum.photos/200" class="img thumbnail" align="middle"/>
button will show a page as below</span>
</div>
</div>
I am talking about the first column!
Okay i got it:
<div class="col-sm-9">
<div class="well">
<h4>Item Price</h4>
<div id="image" style="display:inline;">
<img src="https://picsum.photos/200"/>
</div>
<div id="texts" class="logo"; style="display:inline whitespace:nowrap;">
A very long text(about 300 words)
</div>
</div>
</div>
My css clas:
.logo{
position: relative;
top: -70px; /* This will move it 20px up */
left: 20px; /* This will move it 20px to the right */
}
Thanks to Drown who answered this question
instead of making the logo position relative you can use
margin-top:-70px
margin-left:20px
absolute position for this task is not recommended.
I have a problem I just can't seem to solve despite following directions in my previous post, I just began learning html/css. This is my button as it appears right now:
here
& this is where I would like it to appear. It does not seem to move despite changing the top, left or bottom:
here
& this is where I want it to be. The background is simply an image its not multiple divs. this is the only code I have:
<section>
<div class="content">
<div class="container">
<div class="wrap">
<div class="fix-7-12">
<div><p class="ae-2">
<button style{
top: 100px;
right: 1000px;
left: 10000000px;
}
>Try yourself</button
>
</p></div>>
</div>
</div>
</div>
</div>
<img
src="assets/img/background/fire2.png"
width="1450"
height="850"
></img>
</section>
I think you should use left, top etc. styles with percentages. If we look at the center of the button in the second picture:
top: 35%, left: 60%
Also, you should change display to block in order to see the button as a rectangle element. I gave also width and height. You can change them if you want.
So, I changed your HTML code as:
<section>
<div class="content">
<div class="container">
<div class="wrap">
<div class="fix-7-12">
<div><p class="ae-2">
<button
style="position: absolute; display: block; top: 35%; left: 60%;
width: 120px; height: 60px;">
Try yourself
</button>
</p></div>
</div>
</div>
</div>
</div>
<img
src="assets/img/background/fire2.png"
width="1450"
height="850"
>
</section>
These are the screenshots:
There are a few mistakes in your HTML. Firstly, the style attribute needs to be a string. The position attribute needs to be first. So it would be "position: absolute;top: 100px;right: 1000px; left: 10000000px;". img tags do not have a closing tag.
Correct HTML:
<section>
<div class="content">
<div class="container">
<div class="wrap">
<div class="fix-7-12">
<div><p class="ae-2">
<button style="position: absolute;top: 100px;right: 1000px; left: 10000000px;"
>Try yourself</button
>
</p></div>>
</div>
</div>
</div>
</div>
<img
src="assets/img/background/fire2.png"
width="1450"
height="850"
>
</section>
In this CodePen, I am trying to get the .icon div to appear the full height of the div it's in. Unfortunately, it looks like it's loading before the text is there so the div has a height of 0 when it loads. How would I get it to load once the text is there and grab that full height? Preferably with no JS if possible.
All help is appreciated!
HTML
.faqSection {
height: 600px;
width: 100vw;
}
.topFaqSection {
margin: 100px 0 40px 10vw;
}
.innerFaqSection {
height: 100%;
width: 100%;
display: flex;
justify-content: center;
}
.leftFaq {
width: 35%;
height: 100%;
/* background-color: violet; */
}
.rightFaq {
width: 35%;
height: 100%;
/* background-color: blanchedalmond; */
}
.singleFaqBlock {
margin: 20px 0 0 0;
}
.questionBlock {
background-color: red;
display: flex;
flex-direction: row;
align-content: flex-start;
}
.icon {
background-color: blue;
width: 50px;
height: 100%;
}
.questionText {
/* display: none; */
background-color: green;
width: 100%;
}
.answerBlock {}
.answerBlock p {
margin: 0 0 0 62px;
}
.hiddenText {
display: none;
}
.notHiddenText {
display: block;
}
<div class="faqSection">
<div class="topFaqSection">
<h1>Questions? Look Here</h1>
<div class="bar blue"></div>
</div>
<div class="innerFaqSection">
<div class="leftFaq">
<div class="singleFaqBlock">
<div class="questionBlock">
<div class="icon">
<div class="circle-plus closed">
<div class="circle">
<div class="horizontal"></div>
<div class="vertical"></div>
</div>
</div>
</div>
<div class="questionText">
<h3>
How do I earn a return?
</h3>
</div>
</div>
<div class="answerBlock">
<p class="hiddenText">
Yes! We would love to answer your question thank you for giving us the opoportunity!!
</p>
</div>
</div>
<div class="singleFaqBlock">
<div class="questionBlock">
<div class="icon">
<div class="circle-plus closed">
<div class="circle">
<div class="horizontal"></div>
<div class="vertical"></div>
</div>
</div>
</div>
<div class="questionText">
<h3>
What kind of returns can I expect?
</h3>
</div>
</div>
<div class="answerBlock">
<p class="hiddenText">
Yes! We would love to answer your question thank you for giving us the opoportunity!!
</p>
</div>
</div>
</div>
<div class="space"></div>
<div class="rightFaq">
<div class="singleFaqBlock">
<div class="questionBlock">
<div class="icon">
<div class="circle-plus closed">
<div class="circle">
<div class="horizontal"></div>
<div class="vertical"></div>
</div>
</div>
</div>
<div class="questionText">
<h3>
When is the platform releasing?
</h3>
</div>
</div>
<div class="answerBlock">
<p class="hiddenText">
Yes! We would love to answer your question thank you for giving us the opoportunity!!
</p>
</div>
</div>
<div class="singleFaqBlock">
<div class="questionBlock">
<div class="icon">
<div class="circle-plus closed">
<div class="circle">
<div class="horizontal"></div>
<div class="vertical"></div>
</div>
</div>
</div>
<div class="questionText">
<h3>
Why invest in real estate? </h3>
</div>
</div>
<div class="answerBlock">
<p class="hiddenText">
Yes! We would love to answer your question thank you for giving us the opoportunity!!
</p>
</div>
</div>
<div class="singleFaqBlock">
<div class="questionBlock">
<div class="icon">
<div class="circle-plus closed">
<div class="circle">
<div class="horizontal"></div>
<div class="vertical"></div>
</div>
</div>
</div>
<div class="questionText">
<h3>
I'm a - and interested in raising money through -, what should I do? </h3>
</div>
</div>
<div class="answerBlock">
<p class="hiddenText">
Yes! We would love to answer your question thank you for giving us the opoportunity!!
</p>
</div>
</div>
</div>
</div>
</div>
As I said in a a comment, removing the height: 100% rule should fix it for you. The "why" for it is a bit... unsavory.
Flex children default to "align-self: stretch", so they'll stretch naturally. But when you set a height, it will use that value. The problem is percentage height is calculated from the height actually specified for the parent and .icon's parent (.questionBlock) has no height specified: so .icon gets 100% of 0. If you were to set a height to .questionBlock, .icon would adapt.
From the specs:
The percentage is calculated with
respect to the height of the generated box's containing block. If the
height of the containing block is not specified explicitly (i.e., it
depends on content height), and this element is not absolutely
positioned, the value computes to 'auto'.
This is the comment that pointed me into the right direction. Maybe check it out?
Text over image. I can't seem to get my text over my picture. I tried with absolution and everything.
<div class="wrapper">
<div class="container">
<div class="row">
<div class="stages col col-6">
<img src="styles\images\stage1.jpg" alt="Stage1">
<p>Stage 1</p>
</div>
<div class="stages col col-6">
<img src="styles\images\stage2.jpg" alt="Stage2">
<p>Stage 2</p>
</div>
</div>
</div>
You are not applying it correctly.
To make it work, you need to make the parent div to have a position:relative; and the child div to have position:absolute;
Once you do the position:absolute;, you need to change the positioning by attributes such as top, bottom, left and right with numeric values.
Just in case, if your text is below the image, you can use z-index attribute to bring it up with a numeric value.
For Instance,
<div class="wrapper">
<div class="container">
<div class="row" style="position:relative;">
<div class="stages col col-6">
<img src="styles\images\stage1.jpg" alt="Stage1">
<p style="position:absolute;top: 0;left: 0;">Stage 1</p>
</div>
<div class="stages col col-6">
<img src="styles\images\stage2.jpg" alt="Stage2">
<p>Stage 2</p>
</div>
</div>
</div>
LIVE DEMO
Hope this helps.
It would be better to manage it through classes. Add image-container to the parent div of image, and text-over-img to p tag used for text.
.image-container {
position: relative;
}
.text-over-img {
position: absolute;
background-color: red;
padding: 5px;
border-radius: 5px;
top: 0px;
left: 5px;
margin-top: 5px;
}
DEMO
Code here - http://jsfiddle.net/Cd2Ek/
html -
<div id="main-div" style="height: 250px; margin-left: 10px;">
<div class="sub-div">
<div class="">0%</div> <div class="d1" val="0" style="height: 0%"></div>
<div class=""><small>L1</small></div>
</div>
<div class="sub-div">
<div class="">0%</div> <div class="d1" val="0" style="height: 0%"></div>
<div class=""><small></small></div>
</div>
<div class="sub-div">
<div class="">33%</div> <div class="d1" val="1" style="height: 33%"></div>
<div class=""><small>L3</small></div>
</div>
<div class="sub-div">
<div class="">0%</div> <div class="d1" val="0" style="height: 0%"></div>
<div class=""><small></small></div>
</div>
<div class="sub-div">
<div>67%</div> <div class="d1" val="2" style="height: 67%"></div>
<div class=""><small>L5</small></div>
</div>
</div>
If you see the output in jsfiddle, the bars are going below the main-div. I think you can guess the actual requirement, all bars should be position from bottom, and if the % is 50, then frm bottom, bar should be upto 50% height of the main div, along with label, % indication.
I think this is what you need - fiddle. I've rearranged your code quite a lot to simplify how it works, but basically it uses absolute positioning to get the bars to stick to the bottom. Please let me know if anything is unclear.
Each bar now uses the HTML:
<div class="bar-container">
<div class="bar" style="height:50%">
<span class="percentage">50%</span>
<span class="label">L1</span>
</div>
</div>
Change your css with below one
.sub-div {
margin-right: 6%;
display: inline-block;
height: 250px;
border: 1px solid green;
**vertical-align:top;**
}
Try above code...
CSS
You missed aligning the bars add this line in you .sub-div css class
vertical-align: top;
DEMO