I am using a wordpress and working with a theme. The theme host does not let me insert html directly into the files or let me use ftp. The only way I can do this is by using CSS. I am trying to make it so that a slideshow is at the very top of the page. The theme by default makes the website logo appear at the top which i don't want.
Here is the html
<div id="page" class="site">
<header id="masthead" class="site-header" role="banner">
</header>
<div id="content" class="site-content">
<div id="primary" class="content-area">
<article id="post-2" class="post-2">
<header class="entry-header">
<h1>hello</h1>
</header>
<div class="entry-content">
<div class="metaslider">
</div>
</div>
</article>
</div>
</div>
</div>
I need to make it so that the div with class metaslider comes before everything else in the page. More specifically, metaslider comes before the masthead header element. I tried using position: realtive; top: -500px; but it just overlaps the logo which is not what i want, i want to push the masthead down and put metaslider on top of it.
Try this
#page {
position: absolute;
top: 50px;
}
</style>
Let me know if this does work
I used the following style information and the metaslider div was moved to the top for me.
.entry-header {
position: relative;
margin-top: 220px;
}
.metaslider {
background: rebeccapurple;
height: 200px;
position: absolute;
width: 100%;
left: 0;
top: 0;
}
Please note that since I made the metaslider absolute, I had to give it a width and height to compensate for empty content and the case may very well vary for you.
To test for the rest of the content I replicated the entry-header as entry-body and all seems to be aligned well so far.
Here is my updated HTML and CSS:
<style>
.entry-header {
position: relative;
margin-top: 220px;
}
.metaslider {
background: rebeccapurple;
height: 200px;
position: absolute;
width: 100%;
left: 0;
top: 0;
}
</style>
<div id="page" class="site">
<header id="masthead" class="site-header" role="banner">
</header>
<div id="content" class="site-content">
<div id="primary" class="content-area">
<article id="post-2" class="post-2">
<header class="entry-header">
<h1>hello</h1>
</header>
<div class="entry-content">
<div class="metaslider">
</div>
<header class="entry-body">
<h1>hi</h1>
</header>
</div>
</article>
</div>
</div>
</div>
Related
Is there any way that I could position everything such that the items (such as text/pictures) can overlay?
For example:
<body>
<header>
<div class="navbar">
</div>
</header>
<div class="class1">image</div>
<div class="class2">text</div>
<div class="class3">text</div>
</body>
I want the class 2 text and class 3 to be displayed over the image. However, in this format, they just appear below the image.
I tried putting the class 2 and class 3 inside of class 1
<body>
<header>
<div class="navbar">
</div>
</header>
<div class="class1">image
<div class="class2">text</div>
<div class="class3">text</div>
</div>
</body>
However, I found this very troublesome. Everytime I add a new thing into class 1, the whole page will move.
Even though position: relative; and position: absolute; solves this it won't work if I try to display an element over the whole page itself (outside of class 1 - goes to the bottom of the page). I am trying to have something like this https://www.w3schools.com/howto/howto_js_alert.asp appear over my whole page.
Tried setting the with position: relative; and the alert message box as 'position: absolute;` but this didn't do anything. Could someone please give some suggestions? Thanks a lot!
I'm not sure to understand what you need but maybe your need is something like that :
.class1 {
position: relative;
background-image: url("https://images.sftcdn.net/images/t_app-cover-l,f_auto/p/ce2ece60-9b32-11e6-95ab-00163ed833e7/260663710/the-test-fun-for-friends-screenshot.jpg");
background-size: contain;
background-repeat: no-repeat; height: 100px;
width: 100px;
}
<body>
<header>
<div class="navbar">
</div>
</header>
<div class="class1">
<div class="class2">text2</div>
<div class="class3">text3</div>
</div>
</body>
Yeah , like this.
HTML
<div class="container">
<div class="class1">image</div> //use an img tag here
<div class="text-container">
<div class="class2">text</div>
<div class="class3">text</div>
</div>
</div>
CSS
.container {
position: relative;
text-align: center;
color: white;
}
.text-container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
You need to set you content at bottom of the page the try the solution, it is for bottom right poistion
.class1{
position: absolute;
right: 0;
bottom: 0;
}
<header>
<div class="navbar">
</div>
</header>
<div class="class1">image
<div class="class2">text</div>
<div class="class3">text</div>
</div>
I am trying to put my background behind the div that contains a jumbotron, but the div keeps on staying below the background image, instead of appearing on it. How do I fix this?
P.S : I do not want to put the background image in my CSS file for some reasons, so i want the image src to only be in my HTML. Many thanks!
Here is my code :
<div class="container-fluid" >
<img src='U_Thant_PIC_3.jpg'
width='1400px' height='800px'/>
<div class="jumbotron jumbotron-fluid">
<center>
<h2 class="a">Cats are cool</h2>
</center>
</div>
</div>
In order to achieve this you need to tell the browser to position the img element behind your child div. For the purpose you can use the position attribute, with the img having a lower z-index.
The z-index does work for this, as long as you have position properties on the elements:
div.container-fluid{position:relative;}
div.container-fluid img{position:absolute;top:0;left:0;z-index:1}
div.container-fluid div.jumbotron{position:relative;z-index:5;color:white;}
<div class="container-fluid" >
<img src='https://www.w3schools.com/css/img_lights.jpg'
width='1400px' height='800px'/>
<div class="jumbotron jumbotron-fluid">
<center>
<h2 class="a">Cats are cool</h2>
</center>
</div>
</div>
Try this;
HTML
<div class="container-fluid">
<img src="U_Thant_PIC_3.jpg" alt="Snow" width='1400px' height='800px'>
<div class="jumbotron jumbotron-fluid">
<h2 class="a">Cats are cool
</div>
</div>
CSS
.jumbotron {
position: absolute;
left: 50%;
}
It will give you centered text on top of your image.
Add position: absolute; into the class="jumbotron jumbotron-fluid", and move your <img src='U_Thant_PIC_3.jpg' width='1400px' height='800px'/> to the bottom of code.
.box {
width: 200px;
height: 200px;
position: relative;
overflow: hidden;
}
.jumbotron {
color: white;
position: absolute;
}
<div class="box">
<div class="jumbotron">
textbox
</div>
<img src="https://www.w3schools.com/css/img_lights.jpg">
</div>
You need set up first the parent element with position: relative; in this case you should add the css below.
.container-fluid { position:relative }
and then you need to set up the jumbotron with the next style.
.jumbotron { position: absolute }
with this should be work, also you can move the .jumbotron with the top, bottom, left and right positions, for example:
.jumbotron { position: absolute; top: 20px; left: 10px; }
In this way .jumbotron will move in the area with the first position: relative; taken. In this case in the area of .container-fluid class.
<div class="container-fluid" >
<img src='https://www.w3schools.com/css/img_lights.jpg'
width='1400px' height='800px'/>
<div class="jumbotron jumbotron-fluid">
<center>
<h2 class="a">Cats are cool</h2>
</center>
</div>
</div>
Here I give you and example:
https://jsfiddle.net/mnL8cvf2/2/
Hope this can help you.
This is how it looks so far:
And this is what I need to achieve:
<section class="section sub-masthead--TC2"></section>
<section class="section qualifiers--Q1"></section>
The first <section class=sub-masthead--TC2> element contains the image in some nested divs. With the design above is very clear what I need. I already set position: relative to both sections and z-index: 1 to the upper section and z-index: 3 to the down one but it doesn't work.
This is the whole HTML for the section that contains the image:
<section class="section sub-masthead--TC2">
<div class="sub-masthead__wrapper">
<div class="sub-masthead__tiles">
<div class="sub-masthead-item">
<div class="sub-masthead-item__content">
<div class="sub-masthead-item__copy">
<p><!-- text --></p>
</div>
</div>
<div class="sub-masthead-item__image-container">
<!-- IMAGE HERE -->
<img class="sub-masthead-item__image" src="assets/images/bg_phone-unique.png" alt="" role="img">
</div>
</div>
</div>
</div>
</section>
Here is my try. I have created an example for you to follow along.
First add position: relative to the parent element of both sections or if there is none then the body.
Then add position absolute to image section and manipulate top values.
.sub-masthead--TC2 {
position: absolute;
top: 40px;
right: 0;
}
Result:
.wrapperDiv {
position: relative;
}
.sub-masthead--TC2 {
width: 100%;
height: 100px;
background-color: tomato;
}
.qualifiers--Q1{
width: 300px;
height: 300px;
position: absolute;
top: 40px;
right: 0;
border: 1px solid #000;
padding: 20px;
}
img{
width: 100%;
height: auto;
}
<div class ="wrapperDiv">
<section class="section sub-masthead--TC2"></section>
<section class="section qualifiers--Q1">
<img src="https://placeimg.com/640/480/any" />
</section>
</div>
Since centring my blog content my right hand sidebar has fallen down below my content.
How can I bring it back it up so it sits to the right of my page? (Between the right side border and the edge of the page).
Live link:
https://www.moneynest.co.uk/how-to-choose-a-broker/
Code:
<html>
<body class="post-template-default single single-post postid-594 single-format-standard logged-in admin-bar no-customize-support nolayout windows chrome override" itemscope itemtype="http://schema.org/WebPage"><div class="site-container">
<div class="site-inner">
<div class="content">
<div id="container">
<div class="central-container">
<div class="middle-content">
<div class="inner-post-head">
</div>
<div class="data-content">
<!--MAIN CONTENT HERE -->
</div><!-- End .middle-content -->
</div>
</div><!-- End #container -->
</div><!-- End #content -->
<aside class="sidebar sidebar-primary widget-area" role="complementary" aria-label="Primary Sidebar" itemscope itemtype="http://schema.org/WPSideBar" id="genesis-sidebar-primary"><h2 class="genesis-sidebar-title screen-reader-text">Primary Sidebar</h2><section id="text-9" class="widget widget_text"><div class="widget-wrap"> <div class="textwidget">
<!--SIDE BAR CONTENT HERE--></div>
<!--<div id="popular-articles">
<p class="popular-articles-text">Popular articles</p>
</div>-->
</div>
</div>
</div>
<section id="text-10" class="widget widget_text"><div class="widget-wrap"
</div></section>
</div>
</aside>
<!--END OF SIDEBAR--!>
<!--FOOTER STUFF-->
</body>
</html>
Running Wordpress with custom Genesis theme and Bootstrap.
Your style sheet is having below code
.site-inner, .wrap {
max-width: 1200px;
}
As you have centered your contents with margin-left, this 1200px is not enough to hold your sidebar. SO please change that to below one so that it will work for you
.site-inner, .wrap {
max-width: 100%;
}
Method 2:
Make your content part centralized through out and make your sidebar positioned to right side. Style as follows:
.site-inner{
position: relative;
}
.content {
width: 792px;
margin: 0 auto !important;
float: none;
}
.sidebar-primary {
position: absolute;
width: 240px !important;
right: 0px;
top: 0px;
}
position: fixed;
right: 0;
top: 0;
or instead make it thinner (width:80%) and give the content display: inline
As well as removing the left margin from .content, I'd also recommend removing padding from .site-inner and adding margin:0 auto;.
I tested in your page and did this. It is working. Just decrease your margin-left property in relative media queries.
#media only screen and (min-width: 1200px)
(index):27
.content {
margin-left: 10%;
}
I have a page with the following structure:
<body>
<div id="page">
<div id="header-container">
<header>
</header>
</div>
<div id="main-container">
<div id="main" class="site-main">
<div id="sidebar-container">
<div id="sidebar">
</div>
</div>
<div id="content-container">
<div id="main-banner-container">
<div id="main-banner-holder">
<img id="main-banner" src="http://dummyimage.com/900x300/000/fff" />
</div>
</div>
<div id="content" class="content" role="main">
</div>
</div>
</div>
<div id="footer-container">
<footer>
<div id="footer-images">
</div>
</footer>
</div>
</div>
</div>
</body>
And formatted with the following CSS:
body {
margin: 0 auto;
width: 70%;
background-color: rgb(0,114,187);
font-family: verdana;
}
#header-container {
padding-bottom: 15px;
padding-top: 20px;
padding-left: 35px;
padding-right: 35px;
height: 190px;
}
header {
position: fixed;
width: 66%;
padding-top: 30px;
top: 0px;
}
#sidebar-container {
height:500px;
width:320px;
float:right;
}
#sidebar {
position: fixed;
color: rgb(211,34,52);
padding: 10px;
right: 16.5%;
top:226px;
}
#content-container {
width: 72%;
}
#main-banner-container {
max-width: 900px;
}
Viewing the page on a widescreen shows the content fine. However, as I reduce the window size, or if I view the site on a lower resolution screen, the fixed image and the text underneath it starts to obscure the sidebar, even though it does scale a little. Furthermore, when the page is scrolling, even though some of the text move to make space for the sidebar, the text below it overlaps when scrolled.
A rough example of the problem can be seen here: http://jsfiddle.net/4WQzP/
What changes do I need to make?
EDIT: To clarify, I was hoping a plain CSS/HTML based fix. Javascript is an option, though I'm trying to avoid it since I haven't really used it in this site so far.
for using an adaptive design used two ways)), the first is to use the bootstrap framework, the second is writing media queries