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>
Related
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
I am trying to make a design where some text of id="text-field" will overlap to id="image-field". I have no idea how to do this, Thank you for your help.
<!DOCTYPE html>
<html>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-sm-6" id="text-field"> Some text </div>
<div class="col-sm-6" id="link-field"> Some link </div>
</div>
<div class="row">
<div class="col-sm-12" id="image-field">Background Image </div>
</div>
</div>
</body>
</html>
I made a small re-usable example it's a fairly common thing to do with css here
Here is a example
.box {
position: relative;
}
.box__image {} .box__text {
position: absolute;
bottom: 0;
}
<div class="box">
<div class="box__image">
<img src="http://placehold.it/350x150">
</div>
<div class="box__text">
Testing text
</div>
</div>
Just a small explanation position:relative is used to keep position:absolute elements from going out of their containing div
Using position properties you can ser postion of elements.
#image-field{
position: absolute;
top: 0px;
}
Research on postions property of css.You will get more idea
postion properties
I am going to make a website like this http://watcherboost.com/
SO i want to create middle menu for my website.so i need to create a div tag which is always top on following background:
This is the code i tried
<form id="form1" runat="server">
<div>
<div id="top" style="background-color:#072530; height: 30px;margin-top: -10px;margin-left:auto;margin-right:initial">
</div>
</div>
</form>
<div style="height: 300px;background-color: #0E5D7B; margin-top: 0px;">
</div>
<div style="background-color:#072530; height: 30px;margin-top: -10px;margin-left:auto;margin-right:initial">
</div>
<div style="height: 650px; background-color: #C2C2C2; margin-top: 0px;">
</div>
<div style="background-color:#072530; height: 30px;margin-top: -10px;margin-left:auto;margin-right:initial">
</div>
<div style="height: 300px;background-color: #0E5D7B; margin-top: 0px;">
</div>
<div style="background-color:#072530; height: 30px;margin-top: -10px;margin-left:auto;margin-right:initial">
</div>
<div id="middle" style="margin-left: 150px;margin-right:150px;margin-top:-250px;background-color:black"></div>
I want to get this last div (id =middle) to always top mode like upper website.
But unfortunately my div (id=middle) is not showed the page..
Please advice how to edit this code
Thanks
Your div is not showing up, because it doesn't contain any content. Add height property to its inline CSS.
If you want a div stay on top you should set:
position:fixed;
top:0px;
try this:
https://jsfiddle.net/TiG3R/ug4vvo48/
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
I am making a responsive site for a mobile. The HTML should not be changed but the css should handle the positioning of the elements so as to not effect the main site.
BACKGROUND INFORMATION
The desktop site has a navigation bar set at the bottom of the screen with a contact number below it whilst the site title and logo is placed at the top. For the mobile this is unfeasable so I've put the navigation bar at the top of the screen alongside the title and logo. The number has remained at the bottom as desired. Between the top header and the contact number at the bottom, I have placed the bulk content area. The content is being displayed correctly by using the height:calc(100% - 336px) property to set the content wrapper 100% - the total height of the top header and the contact number. The content wrapper is then set absolute to a position top: 176px to meet the bottom of the top header. The content inside the content wrapper does not fit inside the wrapper so overflow-y:scroll is used to ensure that the user can scroll through the content area.
PROBLEM
The content area within the wrapper is not scrolling.
CODE
CSS
.PageContentBox {
top: 176px!important;
height: calc(100% - 336px);
z-index: 12;
width: 100%;
overflow-y: scroll;
left: 0px!important;
}
#content {
padding: 0;
height: 100%;
overflow-y: scroll; /*This here for testing purposes*/
}
HTML
<div class="PageContentBox">
<div id="content">
<div id="pages">
<div class="page" id="page0">
<h1>HEADER</h1>
<div class="grid grid-pad" style="padding: 0 0 0 0!important">
<div class="row" id="r1">
<div class="col-5-12">
<div class="content">
<img class="megaServiceImage" src="../template/img/gallery/mega/test.jpg" alt="??????" />
</div>
</div>
<div class="col-7-12">
<div class="content">
<h2>Applications</h2>
<p class="MegaServicesText">
DUMMY TEXT
</p>
</div>
</div>
</div>
<div class="row" id="r2">
<div class="col-5-12">
<div class="content">
<img class="megaServiceImage" src="../template/img/gallery/mega/test.jpg" alt="??????" />
</div>
</div>
<div class="col-7-12">
<div class="content">
<h2>Performance</h2>
<p class="MegaServicesText">
DUMMY TEXT
</p>
</div>
</div>
</div>
<div class="row" id="r3">
<div class="col-5-12">
<div class="content">
<img class="megaServiceImage" src="../template/img/gallery/mega/test.jpg" alt="??????" />
</div>
</div>
<div class="col-7-12">
<div class="content">
<h2>Specifications</h2>
<p class="MegaServicesText">
DUMMY TEXT
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
You need to set position on your .PageContentBox: top: and z-index don't work unless you define position.
Here is you updated Fiddle with the position set to absolute.
In your question you save already given the solution just use that only.
You have specified that absolute but not used it in css. Just use it and it will work no need to put the #content css.
css should be like this:
.PageContentBox {
position: absolute;
top: 176px!important;
height: calc(100% - 336px);
z-index: 12;
width: 100%;
overflow-y: scroll;
left: 0px!important;
}
See the example
I am getting desktop and mobile view like this and I think its fine. What you say?