EDIT: I ended up using the second solution here and It works wonderfully. Thanks everyone who helped me solve this issue
I have an image declared in a css file like background:url(). The css file is the 2nd thing on the page to load, but the image is the last thing. This image is the first thing people will see on the site, but it loads last. Is there any way to load this image as soon as the page starts loading?
Edit:
$(document).ready(function() {
resizeDiv();
});
window.onresize = function(event) {
resizeDiv();
}
function resizeDiv() {
vpw = $(window).width();
vph = ($(window).height());
$('#mainPic').css({
'height': vph + 'px'
});
$('#mainPicContent').css({
'height': vph + 'px'
});
}
body,
html {
width: 100%;
height: 100%;
margin: 0;
}
h1 {
color: white;
}
#mainPic {
width: 100%;
top: 0;
left: 0;
right: 0;
-webkit-box-shadow: inset 0px 0px 28px 0px rgba(0, 0, 0, 0.53);
-moz-box-shadow: inset 0px 0px 28px 0px rgba(0, 0, 0, 0.53);
box-shadow: inset 0px 0px 28px 0px rgba(0, 0, 0, 0.53);
background: url(//upload.wikimedia.org/wikipedia/commons/0/0e/Tree_example_VIS.jpg) no-repeat center center;
background-size: cover;
background-color: #4a565d;
}
#mainPic::before {
position: relative;
top: 0;
left: 0;
right: 0;
display: block;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
content: "";
}
.centerText {
position: relative;
top: 40%;
transform: translateY(-50%);
text-align: center;
width: 100%;
margin-right: auto;
margin-left: auto;
left: 0;
right: 0;
}
.centerBtn {
height: 50px;
width: 200px;
background-color: transparent;
color: #fff;
display: block;
border-radius: 25px;
border: 1px solid white;
transition: ease-in-out 0.15s;
font-family: arial;
}
.centerBtn:hover {
background-color: white;
color: rgb(14, 143, 185) !important;
cursor: pointer;
border-radius: 25px;
border: 1px solid rgb(134, 134, 134);
transition: ease-in-out 0.15s;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="mainPic" style="">
<div id="mainPicContent" style="position:absolute;top:75px;left:0;right:0;cursor:default;">
<div class="centerText">
<div style="width:850px;margin-right:auto;margin-left:auto;">
<h1 style="margin:0;margin-bottom:20px;">Header</h1>
<div style="width: 725px;height: 5px;margin-right: auto;margin-left: auto;">
<a class="centerBtn" style="float:left;margin-left:145px;" href="#">
<p>Button</p>
</a>
<a class="centerBtn" style="float:right;margin-right:145px;" href="#">
<p>Button</p>
</a>
</div>
</div>
</div>
</div>
</div>
As far as I can tell thats everything relavant to the picture - let me know if you need anything else
Edit 2: Jsfiddle
Related
I'm creating a SignalR Web Application for messaging. The messages being sent seem to overlap with the footer (textbox, send button), and additionally, not scroll along with the messages being sent.
My CSS is as follows:
body {
background-color: #2d3436;
}
.container {
background-color: #2d3436;
padding: 20px;
color: white;
max-height: 80%;
}
.textmessaging {
background-color: #474f52;
padding: 20px;
position:fixed;
bottom: 0;
width: 100%;
}
#message::-webkit-scrollbar {
width: 8px;
}
/* Track */
#message::-webkit-scrollbar-track {
-webkit-border-radius: 10px;
border-radius: 10px;
}
/* Handle */
#message::-webkit-scrollbar-thumb {
-webkit-border-radius: 10px;
border-radius: 10px;
background: rgba(67, 74, 139, 0.8);
}
#message::-webkit-scrollbar-thumb:window-inactive {
background: rgba(67, 74, 139, 0.4);
}
#message {
resize: none;
outline: none;
background-color: rgba(0, 0, 0, 0.1);
width: 94%;
color: white;
}
#sendmessage {
margin: 0;
position: absolute;
height: 50%;
width: 5%;
outline: none;
top: 50%;
margin-left: 1%;
-ms-transform: translateY(-50%);
transform: translateY(-50%);
background-color: rgba(0, 0, 0, 0.25);
border: none;
border-radius: 6px;
font-size: x-large;
}
#sendmessage:hover {
transition: all 0.3s ease;
background-color: rgba(0, 0, 0, 0.4);
}
#lightmodetoggle {
background-color: rgba(0, 0, 0, 0.25);
border: none;
margin: 10px;
border-radius: 6px;
font-size: x-large;
position: fixed;
outline: none;
}
#lightmodetoggle:hover {
transition: all 0.3s ease;
background-color: rgba(0, 0, 0, 0.4);
}
#discussion {
list-style-type: none;
}
#messagestyle {
padding: 5px;
border: 1px solid grey;
border-radius: 6px;
margin-bottom: 3px;
}
My HTML is as follows:
<div id="maincontent">
<div class="container" id="data">
<ul id="discussion">
</ul>
</div>
<div class="textmessaging">
<textarea id="message" placeholder="Message..." rows="3" cols="50"></textarea><button id="sendmessage" data-toggle="tooltip" title="Send!"><i class='far fa-paper-plane'></i></button>
<input type="hidden" id="displayname" />
</div>
</div>
JS as follows
<script src="Scripts/jquery-3.4.1.min.js"></script>
<!--Reference the SignalR library. -->
<script src="Scripts/jquery.signalR-2.2.2.min.js"></script>
<!--Reference the autogenerated SignalR hub script. -->
<script src="signalr/hubs"></script>
<!--Add script to update the page and send messages.-->
<script type="text/javascript">
$(function () {
// Declare a proxy to reference the hub.
var chat = $.connection.chatHub;
// Create a function that the hub can call to broadcast messages.
chat.client.broadcastMessage = function (name, message) {
// Html encode display name and message.
var encodedName = $('<div />').text(name).html();
var encodedMsg = $('<div />').text(message).html();
// Add the message to the page.
$('#discussion').append('<div><li id="appendedmsg"><strong>' + encodedName
+ '</strong><br><a id="messagestyle">' + encodedMsg + '<a></li></div>');
};
// Get the user name and store it to prepend to messages.
$('#displayname').val(prompt('Enter your name:', ''));
// Set initial focus to message input box.
$('#message').focus();
// Start the connection.
$.connection.hub.start().done(function () {
$('#sendmessage').click(function () {
// Call the Send method on the hub.
chat.server.send($('#displayname').val(), $('#message').val());
// Clear text box and reset focus for next comment.
$('#message').val('').focus();
});
});
});
// var msg = document.getElementById("message");
// var button = document.getElementById("sendmessage");
// textBox.addEventListener("keyup", function (event) {
// if (event.keyCode == 13) {
// button.click();
// }
// });
$(document).ready(function () {
$('[data-toggle="tooltip"]').tooltip();
});
I've done some searching for a while and haven't found anything that suits my needs.
hope this can help, I make a little bit changes in your css code
body {
background-color: #2d3436;
margin: 0;
}
.container {
background-color: #2d3436;
padding: 20px;
color: white;
max-height: 80%;
}
.textmessaging {
background-color: #474f52;
padding: 20px;
position:fixed;
bottom: 0;
width: auto;
left: 0;
display: block;
right: 0;
}
#message::-webkit-scrollbar {
width: 8px;
}
/* Track */
#message::-webkit-scrollbar-track {
-webkit-border-radius: 10px;
border-radius: 10px;
}
/* Handle */
#message::-webkit-scrollbar-thumb {
-webkit-border-radius: 10px;
border-radius: 10px;
background: rgba(67, 74, 139, 0.8);
}
#message::-webkit-scrollbar-thumb:window-inactive {
background: rgba(67, 74, 139, 0.4);
}
#message {
resize: none;
outline: none;
background-color: rgba(0, 0, 0, 0.1);
width: calc(100% - 92px);
color: white;
display: inline-block;
}
#sendmessage {
max-width: 72px;
margin: 0;
position: relative;
height: 49px;
width: 5%;
outline: none;
/* top: 50%; */
margin-left: 1%;
-ms-transform: translateY(-50%);
/* transform: translateY(-50%); */
background-color: rgba(0, 0, 0, 0.25);
border: none;
border-radius: 6px;
font-size: x-large;
display: inline-block;
float: right;
vertical-align: top;
}
#sendmessage:hover {
transition: all 0.3s ease;
background-color: rgba(0, 0, 0, 0.4);
}
#lightmodetoggle {
background-color: rgba(0, 0, 0, 0.25);
border: none;
margin: 10px;
border-radius: 6px;
font-size: x-large;
position: fixed;
outline: none;
}
#lightmodetoggle:hover {
transition: all 0.3s ease;
background-color: rgba(0, 0, 0, 0.4);
}
#discussion {
list-style-type: none;
}
#messagestyle {
padding: 5px;
border: 1px solid grey;
border-radius: 6px;
margin-bottom: 3px;
}
i.far.fa-paper-plane {}
<!-- FontAwesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div id="maincontent">
<div class="container" id="data">
<ul id="discussion">
</ul>
</div>
<div class="textmessaging">
<textarea id="message" placeholder="Message..." rows="3" cols="50"></textarea><button id="sendmessage" data-toggle="tooltip" title="Send!"><i class='far fa-paper-plane'></i></button>
<input type="hidden" id="displayname" />
</div>
</div>
First of all excuse me for explanation if I am not up to the mark, as this is my first post in this platform, Well, I am working on overlay where it has to be shown in right side of the page with given width of say 416px and 100vh of height, but things are getting cut if I do decrease the browser window and as I am decreasing the size of the browser window the button at bottom start appearing on content of overlay which has to remain at bottom even the height is getting decreased, here is the my code as below:
.advanced-overlay {
width: 100%;
min-height: 100vh;
background-color: rgba(35, 0, 18, 0.5);
position: fixed;
z-index: 100002;
top: -41px;
left: 0;
bottom: 0;
.advance-overlay-footer {
display:flex;
justify-content: space-between;
align-items:center;
position: fixed;
right: 24px;
width:156px;
bottom: 24px;
height:6%;
}
.advanced-overlay-content {
position: relative;
// min-height: 83vh;
width: 416px;
margin-top: 108px;
margin-left: auto;
margin-right: 6px;
opacity: 1;
z-index: 100004;
border-radius: 16px 16px 16px 16px;
background-color: #f5f4f6;
box-shadow: 0 2px 30px 0 rgba(0, 0, 0, 0.07),
0 19px 18px 0 rgba(0, 0, 0, 0.05), 0 8px 12px 0 rgba(0, 0, 0, 0.05),
0 1px 5px 0 rgba(0, 0, 0, 0.04), 0 0 2px 0 rgba(0, 0, 0, 0.03);
.close-advance-overlay {
position: absolute;
background-color: #fff;
width: 110px;
height: 40px;
display: flex;
border-radius: 20px;
padding: 5px 22px;
top: -18px;
right: 155px;
opacity: 1;
cursor: pointer;
img {
height: 20px;
width: 20px;
align-self: center;
}
.button-text {
align-self: center;
margin-left: 5px;
font-weight: 600;
font-size: 16px;
color: #000000;
}
}
.advnaced-overlay-content-secion {
//min-height:89vh;
width: 100%;
bottom:10%;
// height:100vh;
.select-box {
margin-top: 40px;
margin-bottom: 40px;
}
.accordinan-filter {
margin-bottom: 24px;
}
.accordian-title {
font-weight: 900;
}
.accordian-content {
margin: 0;
font-size: 16px;
}
}
}
}
.is-maximum {
height: 73vh;
overflow-y: auto;
overflow-x: hidden;
&::-webkit-scrollbar {
width: 4px;
background-color: #fff;
}
&::-webkit-scrollbar-thumb {
border-radius: 3px;
background-color: #d3d3d3;
}
}
<div class="advanced-overlay" v-if="toggleFilter">
<div class="advanced-overlay-content">
<div class="close-advance-overlay" #click="toggleAdvanceFilterOverlay">
<img class src="../assets/icons/close.svg" />
<span class="button-text">Close</span>
</div>
<div class="advnaced-overlay-content-secion is-maximum">
<div class="select-box"></div>
<div class="accordinan-filter"></div>
</div>
<div class="advance-overlay-footer">...two buttons</div>
</div>
</div>
So, I what I would like to achieve eventually is that, I want respsonsive overlay at right side of the browser window, provided if I am decreasing height of the browser the buttons at bottom should stay there (fixed position) and content should be within limit of .advnaced-overlay-content-secion
for a responsive design I recommend you to read into the use of grid and espacially for mobile designs also the use of #media breakpoints.
for having some thing to stick at the bottom simply use:
position: fixed;
bottom: 0;
The text wont display on-top of the video.
I am basically wanting a title which i called Heading to display overlaid on the video. I have tried fiddling with z-index and it does not change, i did notice when I replace the video for an image the text worked, that was using different css code, I am assuming their is a problem with the css.
Please help me, THANK YOU.
CSS CODE:
.home-subheading {
font-family: 'Montserrat',sans-serif;
font-size: 14px;
letter-spacing: .5px;
font-weight: 400;
color: #ccc;
z-index:999!important;
}
.tp-banner .home-subheading {
line-height: 40px!important;
#home-revolution-slider {
width: 100%;
height: 100%;
min-height: 100%;
z-index: -99;
}
.hero {
position: fixed;
z-index: -99;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-size: cover;
}
.content {
position: relative;
z-index: 3;
background-color: #fff;
}
.home-heading,
.home-subheading,
.home-button {
position: absolute;
z-index: 999;
text-align: center;
transform: translateY(0px);
/*-webkit-transition: 1s opacity ease-in-out;*/
}
.tp-loader.spinner1 {
width: 40px;
height: 40px;
background: url(../img/assets/rev-loader.gif) no-repeat center center;
background-color: transparent;
box-shadow: none;
-webkit-box-shadow: none;
margin-top: -20px;
margin-left: -20px;
-webkit-animation: none;
animation: none;
border-radius: 0;
-moz-border-radius: 0;
-webkit-border-radius: 0;
}
.tp-banner-container{
width:100%;
position:relative;
padding:0;
margin-top: 0;
z-index: -1;
}
.tparrows.preview4:after {
background: #fff;
background: rgba(255,255,255,.05);
}
.tp-caption a {
color: #fff;
padding: 9px 22px;
box-shadow: 0 -3px rgba(0, 0, 0, 0.3) inset;
-moz-box-shadow: 0 -3px rgba(0, 0, 0, 0.3) inset;
-webkit-box-shadow: 0 -3px rgba(0, 0, 0, 0.3) inset;
-o-box-shadow: 0 -3px rgba(0, 0, 0, 0.3) inset;
margin: 0 7px 0 7px;
text-transform: uppercase;
}
.tp-caption a:hover {
color: #fff;
}
.html5-video-container video {
width: 100%!important;
height: auto!important;
left: 0!important;
z-index: -99;
}
.tp-banner-video video{
min-width: 100%;
z-index: -3;
HTML CODE:
<!-- MAIN IMAGE -->
<video src="img/coding.mp4" autoplay loop alt="video_typing_cover" data-bgposition="center center" data-bgfit="cover" data-bgrepeat="repeat"></video>
<!-- LAYERS -->
<!-- Home Heading -->
<div class="tp-caption sft"
data-x="center"
data-y="260"
data-speed="1200"
data-start="1100"
data-easing="Power3.easeInOut"
data-splitin="none"
data-splitout="none"
data-endspeed="300"
style="z-index: 4; max-width: auto; max-height: auto; white-space:normal;">
<h2 class="home-heading op-1">Digital Hive</h2>
</div>
<!-- LAYER NR. 1 -->
<div class="tp-caption tp-fade fadeout fullscreenvideo"
data-x="0"
data-y="0"
data-speed="1000"
data-start="1100"
data-easing="Power4.easeOut"
data-elementdelay="0.01"
data-endelementdelay="0.1"
data-endspeed="1500"
data-endeasing="Power4.easeIn"
data-autoplay="true"
data-autoplayonlyfirsttime="false"
data-nextslideatend="true"
data-volume="mute"
data-forceCover="1"
data-aspectratio="16:9"
data-forcerewind="on"
style="z-index: 2;">
<video class="img-responsive" preload="none"
poster='example'>
<source src='img/coding.mp4' autoplay type='video/mp4' />
</video>
</div>
I have two questions...
How do I make the #LeftTable and drop-down menu to keep their position on the page, regardless of the window size?
As it is right now, it will move to be relative to the size of the window. I'd rather it stay in exactly the same place on the background picture (even if it means having scrolling bars at the bottom of the browser). How do I do this?
How do I get the HTML link to work within the button?
body {
background-color: gray;
background-image: url('images/backgroundpic.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
}
ul {
list-style-type: none;
position: fixed;
bottom: 0;
margin: 0;
padding: 0;
background-color: #333;
}
li {
float: left;
}
li a,
.dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover,
.dropdown:hover .dropbtn {
background-color: #87cefa;
}
li.dropdown {
display: inline-block;
}
ul li {
position: relative;
}
.dropdown-content {
display: none;
position: absolute;
bottom: 30px;
left: 0;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content a:hover {
background-color: #f1f1f1
}
.dropdown:hover .dropdown-content {
display: block;
}
input#gobutton {
position: relative;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) cursor: pointer;
padding: 5px 25px;
background: #87CEFA;
border: 1px solid #1E90FF;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: 0 0 4px rgba(0, 0, 0, .75);
-moz-box-shadow: 0 0 4px rgba(0, 0, 0, .75);
box-shadow: 0 0 4px rgba(0, 0, 0, .75);
color: #f3f3f3;
font-size: 1.1em;
}
input#gobutton:hover,
input#gobutton:focus {
background-color: #000080;
-webkit-box-shadow: 0 0 1px rgba(0, 0, 0, .75);
-moz-box-shadow: 0 0 1px rgba(0, 0, 0, .75);
box-shadow: 0 0 1px rgba(0, 0, 0, .75);
}
#LeftTable {
position: absolute;
width: 25%;
min-width: 25%;
right: 75%;
left: 25%;
top: 25%;
bottom: 50%;
Right: 100px;
border: 1px;
color: black;
font-weight: bold;
background-color: white;
opacity: 0.5;
filter: alpha(opacity=50);
border: 1px solid black;
padding: 5px;
}
<table id = "LeftTable">
<tr>
<td width = "20%"></td>
<td width = "80%" id='test'>
<table>
<tr><td>Left</td></tr>
<tr><td>Left</td></tr>
</table>
</td>
</tr>
</table>
<table class="gobutton" align="center">
<tr>
<td>
<div class="b_left"></div>
<div class="b_middle">
<input id="gobutton" type="submit" value="LISTEN" />
<a href="http://www.google.com">
</a>
</div>
<div class="b_right"></div>
</div>
</td>
</tr>
</table>
For your link:
You link works however in your example it's trying to open in a frame so its failing. If you create a html file on your computer, or host the html on a site it should work. I tested this on my computer and the link does work like this:
<a href="http://www.google.com">
<input id="gobutton" type="submit" value="LISTEN" />
</a>
For your table
if you want the position to never change you should not use percentages you should use measurements like pixels.
so instead of
#LeftTable {
position: absolute;
width: 25%;
min-width: 25%;
right: 75%;
left: 25%;
top: 25%;
...
you would have something like:
#LeftTable {
position: absolute;
width: 25%;
min-width: 25%;
right: 50px; //in pixels
left: 50px; //in pixels
top: 50px; //in pixels
...
also you may have to wrap your tables in a div and apply the background to that if you want the image t move with the left table:
<div class="main">
//tables
</div>
.main{
background-image: url('imageurl');
width:100%;
height:100%;
position: absolute;
bottom: 0;
margin: 0;
}
here's an example: http://codepen.io/nilestanner/pen/EgNXwE
I have some image thumbnails and, on hover, I want the title to be displayed on top of a transparent black <div> overlay which covers the width and height of the thumbnail.
I'm using display: table and display: table-cell; respectively (to allow for vertical middle positioning).
However, every time I try this, the overlay <div> is acting as a small strip rather than covering the whole <div>.
I've tried adding padding and margins but am still unable to get my desired behaviour.
http://jsfiddle.net/jameshenry/t92qukz8/2/
The CSS:
.griditem {
position: relative;
background-color: #777;
-webkit-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
-moz-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
width: 50%;
overflow: hidden;
}
.titles {
position: absolute;
display: table;
left: 0px;
top: 0px;
bottom: 0px;
right: 0px;
width: 100%;
opacity:0;
-webkit-transition: opacity .5s ease;
-moz-transition: opacity .25s ease;
background: rgba(0, 0, 0, 0.5);
color: #FFFFFF;
text-decoration: none;
z-index: 999;
}
.titles p {
display: table-cell;
vertical-align: middle;
text-align: center;
text-decoration: none;
}
.griditem:hover .titles {
text-decoration: none;
opacity:1;
}
h5 {
font-family: Helvetica Neue;
font-size: 5em;
color: #FFFFFF;
padding-bottom:0;
margin-bottom:-30px;
}
h6 {
padding-top: 0;
}
}
and the HTML
<div class="griditem" style="background-image:url(https://upload.wikimedia.org/wikipedia/commons/8/80/Aspect_ratio_-_16x9.svg); background-size:100% 100%;">
<img src="http://i.imgur.com/JnW9SPx.png" width="100%" alt="Spacer 16x9" />
<a href="http://www.google.com" class="titles">
<p>BIG TEXT<br>
small Title<p>
</a>
</div>
How can I alter my css/html to get my desired behaviour?
In order to have the table take up 100% height, it needs to have a height context to reference (since no parent is set to any 'height', it collapses). Your problem can be solved by adding a wrapper to your table that sets that context, and adding height:100%; to your display:table; element.
.griditem {
position: relative;
background-color: #777;
-webkit-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
-moz-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
width: 50%;
overflow: hidden;
}
/*added overlay CSS*/
.overlay {
position: absolute;
left: 0px;
top: 0px;
bottom: 0px;
right: 0px;
width: 100%;
height: 100%;
}
.titles {
display: table;
width: 100%;
height: 100%; /*important, forces to 100% height of parent*/
opacity:0;
-webkit-transition: opacity .5s ease;
-moz-transition: opacity .25s ease;
background: rgba(0, 0, 0, 0.5);
color: #FFFFFF;
text-decoration: none;
z-index: 999;
}
.titles p {
display: table-cell;
vertical-align: middle;
text-align: center;
text-decoration: none;
}
.griditem:hover .titles {
text-decoration: none;
opacity:1;
}
h5 {
font-family: Helvetica Neue;
font-size: 5em;
color: #FFFFFF;
padding-bottom:0;
margin-bottom:-30px;
}
h6 {
padding-top: 0;
}
<div class="griditem" style="background-image:url(https://upload.wikimedia.org/wikipedia/commons/8/80/Aspect_ratio_-_16x9.svg); background-size:100% 100%;">
<img src="http://i.imgur.com/JnW9SPx.png" width="100%" alt="Spacer 16x9" />
<div class="overlay">
<a href="http://www.google.com" class="titles">
<p>BIG TEXT<br>
small Title<p>
</a>
</div>
</div>
You could easily solve this by using a bit of jquery like so. Demo can be found here.
var pheight = $(".griditem").height();
$(".titles p").css("height", pheight);
$(window).resize(function () {
var pheight = $(".griditem").height();
$(".titles p").css("height", pheight);
});