I have a simple program that echoes images out to a page from a database. I want to have a child element, just a simple slightly transparent box shown on top of the images.
I know child elements always has a higher z-index than it's parent but the image always covers over the box I want on top. When the page is loading I can see the box in the position I want but then when the images load and the box it disappears.
Here is a jsFiddle: http://jsfiddle.net/EBvCZ/
PHP
echo '<div id="wrapper">';
while ($data = mysql_fetch_array($query_run)) {
echo '<div id="picback"><div id="centerpic"><'.'img src="resizeimage.php?photo_id='.$data['photo_id'].'">';
echo '<br style="clear:both;" />';
echo '<div id="titlepic">This is an image</div>';
echo '</div></div>';
}
echo '</div>
CSS
#wrapper {
overflow:auto;
width:1000px;
height:1000px;
margin: 20px auto;
}
#titlepic {
background-color:rgba(0, 0, 0, 0.5);
top:100px;
width:200px;
height:35px;
position:relative;
}
#centerpic {
position:relative;
margin:auto;
width: 200px;
height: 150px;
top:18.75px;
overflow:hidden;
}
#picback {
position:relative;
margin:10px 23px;
top:75px;
float:left;
width:250px;
height:187.5px;
overflow:hidden;
}
#picback:hover {
background-color:rgb(190,190,190);
-webkit-border-radius:0.4em;
-webkit-transition: background-color 0.5s;
}
Here is a working js fiddle:
http://jsfiddle.net/XKHZv/3/
I did some .css changes and also moved one div before the titlepic.
Here is your new .css:
#wrapper {
overflow:auto;
width:1000px;
height:1000px;
margin: 20px auto;
}
#titlepic {
margin-left:auto;
margin-right:auto;
background-color:rgba(0, 0, 0, 0.5);
width:200px;
height:35px;
position:relative;
clear: both;
}
#centerpic {
position:relative;
margin:auto;
width: 200px;
height: 150px;
top:18.75px;
overflow:hidden;
}
#picback {
position:relative;
margin:10px 23px;
top:75px;
float:left;
width:250px;
height: 203.75px;
overflow:hidden;
}
#picback:hover {
background-color:rgb(190, 190, 190);
-webkit-border-radius:0.4em;
-webkit-transition: background-color 0.5s;
}
Then you also have to move a div closing to before the title pic.
Related
I'm currently setting up a sidebar menu for my Wordpress website. I'm running into 2 issues. The 1st one is that the text in the menu isn't lining up to the left side properly. I have tried to use the text-align attribute but it doesn't work.
The 2nd problem is that there is a bit of random space at the bottom of the menu that I don't know why is there.
Problem is happening here: http://dreamedbig.com/our-services/
My HTML/PHP:
<div class="page-content">
<div id="services-menu" class="services-sidebar">
<?php dynamic_sidebar('services'); ?>
</div>
</div>
The CSS:
#services-menu {
border: 1px solid black;
align-items: left;
float:left;
height: auto;
display: inline-block;
top:0;
left:0;
background-color: #BCE6FB;
}
#services-menu li{
list-style-type:none;
border-bottom: 1px solid black;
}
#services-menu a {
text-decoration: none;
color: #08203D;
}
#services-menu ul {
}
#services-menu ul li a {
position: relative;
display: block;
box-sizing: border-box;
z-index: 1;
margin: 5px;
padding-left: 5px;
padding-right: 5px;
}
#services-menu ul li a::after
{
content: "";
position: absolute;
top:0;
left: 0;
background-color: #00A2DA;
width: 0%;
height: 100%;
transition: all 1s;
z-index: -1;
}
#services-menu ul li a:hover::after
{
width: 100%;
}
#services-menu ul li:nth-child(odd) a::after
{
background-color: #00A2DA;
}
#services-menu ul li:nth-child(even) a::after
{
background-color: #FFFFFF;
}
It looks like you have some inherited styles from classes called .widget and there is margin and padding added to ul. This is common is your using something like WordPress or underscores that come with some stylesheets.
I think these styles will correct it
.widget, #services-menu ul{
margin:0;
padding:0;
}
I found the unwanted margin and padding by using inspect in my chrome browser. I highly recommend it for frontend styling because it makes troubleshooting these kinds of issue easier to resolve.
Here is an article to better explain how it works
#charset "UTF-8";
#moviesbox{
white-space: nowrap;
background-color: #363e4f;
width:4000px;
position:absolute;
overflow:auto;
}
.slider {
position: relative;
width: 155px;
display: inline-block;
background-color: #D4D4D4;
margin-bottom: 2em;
height: 300px;
padding: 3px;
white-space: normal;
}
h1 {
color: #00ff00;
}
p {
background-color: transparent;
color: #ffffff;
}
div
{
color: #00cc00;
}
div #controls
{
color: red;
}
div a
{
color: #00cc00;
}
div a:active {
color: #00cc00;
}
div a:hover {
color: #F58100;
}
<!--/MAIN PANEL/-->
#parent {
width:400px;
}
#controls, #monitor {
float:left;
margin-top:0px;
padding-below:200px;
height:400px;
width:50%;
border:1px;
display:inline-block;
solid rgba(0,0,0,1);
text-align:center;
}
<!--/CONTENT AND CONTROLS/-->
#detail {
width:320px;
height:180px;
margin-bottom:12px;
border: 1px solid #000000;
}
h1text {
color: #fb667a;
font-size: 16px;
font-weight: bold;
float:left;
width:159px;
white-space:pre-wrap;
background: transparent;
}
.year {
float:left;
background: transparent;
}
img {
margin-bottom: 5px;
background:#fff;
cursor:pointer;
transform: scale(1);
-moz-box-shadow: 0px 1px 5px 0px #00cc00;
-webkit-box-shadow: 0px 1px 5px 0px #00cc00;
box-shadow: 0px 1px 5px 0px #00cc00;
}
img:hover {
opacity: 0.5;
cursor:pointer;
transform: scale(1);
visibility:visible;
transition: all .2s ease-in-out;
transform: scale(1.1);
z-index:100;
transition-timing-function:cubic-bezier(0.5, 0, 0.1, 1);
transition-duration:400ms;
}
::-webkit-scrollbar {
width: 0px; /* remove scrollbar space */
background: transparent; /* optional: just make scrollbar invisible */
}
/* optional: show position indicator in red */
/*::-webkit-scrollbar-thumb {
background: #FF0000;
}*/
#detail div {
position:relative;
width:100%;
height:100%;
}
#detail div img {
position: absolute;
top: 0;
left:0;
width:100%;
height: 400px;
z-index:1;
}
#detail div span {
color:#ffffff;
position:absolute;
margin
bottom:0;
right:0;
text-align:center;
width:100%;
background: #00cc00;
opacity: .8;
z-index:2;
}
#detail div span2 {
color:#ffffff;
position:absolute;
top:200px;
right:10px;
text-align:center;
width:50%;
height:200px;
background: #F58100;
opacity: .8;
z-index:10;
}
#links img {
width:10%;
height:30%;
margin-left:16px;
margin-top:100px;
}
<!--/SLIDER/-->
.track {
position: absolute;
top: 10px;
left: 10px;
margin: 0;
padding: 0;
border: 0;
width: 2000px;
}
.book {
float: left;
margin: 0;
margin-right: 10px;
padding: 0;
border: 0;
width: 150px;
height: 150px;
-webkit-transition: opacity 0.2s;
-moz-transition: opacity 0.2s;
-ms-transition: opacity 0.2s;
-o-transition: opacity 0.2s;
-webkit-transition: opacity 0.2s;
}
.book:hover {
opacity: 0.5;
}
.book:nth-child(1) {
background-color: #ff0000;
}
.book:nth-child(2) {
background-color: #ffaa00;
}
.book:nth-child(3) {
background-color: #ffff00;
}
.book:nth-child(4) {
background-color: #00ff00;
}
.book:nth-child(5) {
background-color: #0000ff;
}
.book:nth-child(6) {
background-color: #aa00ff;
}
.book:nth-child(7) {
background-color: #ff00ff;
}
.left, .right {
position: absolute;
color: white;
font-size: 48px;
top: 57px;
cursor: pointer;
z-index: 1;
}
.left {
left: 0;
}
.right {
right: 0;
}
<?php
//database connection
$host = 'localhost';
$user = 'root';
$pass = 'root';
$db = 'pixbeans';
/* 1) mysqli and mysqli result objects */
//$mysqli is object of mysqli class
$mysqli = new mysqli($host,$user,$pass,$db);
//print_r($mysqli);die;
//call query method of $mysqli object
$result = $mysqli->query
//SELECT queries are always return as mysqli result objects
("SELECT * FROM movies WHERE year BETWEEN 2000 AND 2016 ORDER BY rand() LIMIT 20")
or die($mysqli->error);
?>
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>pixBeans - Original Black TV Series</title>
<meta name="author" content="Antonio James">
<link rel="shortcut icon" href="assets/Icons/pixBeans icon.png">
<link href="tabpan.css" rel="stylesheet" type="text/css">
</head>
<style>*{margin: 0px; padding: 0px; background-color:black;}</style>
<body>
<div id="main-wrapper">
<div id="moviesbox" style="display:inline-block;">
<?php while ($movie = $result->fetch_assoc()): ?>
<div id="left1" class="left"><</div>
<div id="right1" class="right">></div>
<div class="slider" >
<img width='<?php 67*2.3 ?>' height='<?= 98*2.3 ?>' src='<?= $movie['image_url'] ?>'> <br>
<h1text><?= $movie['title'] ?></h1text> <br>
<span class='year'>(<?= $movie['year'] ?>)</span>
</div>
</div>
<?php endwhile; ?>
<script src="jquery-mobile/jquery-1.11.1.min.js"></script>
<script src="javascript/tabpan.js"></script>
<script src="javascript/imgjump.js"></script>
<script src="javascript/imgslider.js"></script>
</body>
</html>
I am trying to make all my images display on one horizontal line/row that can be scrolled left or right. However, no matter what I do I cannot seem to make the images quit wrapping to the next line. They are responsive so if i make the screen small 2 images will appear and the rest wraps to a new line. If i make full screen several images appear and the other 15 wrap accordingly. However, I want them to stay on one line. I dont care if the overflow is hidden or if the overflow scrolls in from off the page, I just want them to quit wrapping.
Here is what the site looks like right now:
screen shot. I made the parent div"moviesbox" dark grey so that you can see how far the div extends and I am using light grey to show the div area.
Here is the code that I am using to generate the images into the divs:
<div id="moviesbox" style="display:inline-block;">
fetch_assoc()): ?>
<div id="left1" class="left"><</div>
<div id="right1" class="right">></div>
<div class="slider" >
<img width='<?php 67*2.3 ?>' height='<?= 98*2.3 ?>' src='<?= $movie['image_url'] ?>'> <br>
<h1text><?= $movie['title'] ?></h1text> <br>
<span class='year'>(<?= $movie['year'] ?>)</span>
</div>
Here is the CSS I am using. I PREFER TO USE CSS but if not, i'm open to other fixes.
#moviesbox{
white-space: nowrap;
background-color: #363e4f;
width:4000px;
position:absolute;
overflow:auto;
}
.slider {
position: relative;
width: 155px;
display: inline-block;
background-color: #D4D4D4;
margin-bottom: 2em;
height: 300px;
padding: 3px;
white-space: normal;
}
THanks.
I am fetching ads name from the database and populating in my webpage but as it increases it overlaps the container.
I need to increase the div container as ads increases in ads_container and vice versa.
My PHP Code for the webpage is
<div id="ads_container">
<?php
//current URL of the Page. cart_update.php redirects back to this URL
$current_url = base64_encode($url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
$results = $mysqli->query("SELECT * FROM ads ORDER BY ad_id ASC");
if ($results) {
//fetch results set as object and output HTML
while($obj = $results->fetch_object())
{
echo '<div class="ads">';
echo '<div class="ad"><img src="images/'.$obj->ad_img_name.'"></div>';
echo '</div>';
}
}
?>
</div><!-- End of div ads_container -->
My CSS code
/* default marging and padding of website */
*{
margin:0px;
padding: 0px;
}
#container{
width:900px;
height:auto;
background:#CCCCCC;
margin-right:auto;
margin-left:auto;
position:relative;
}
/* HEADER SECTION */
#mainheader{
width:900px;
height:70px;
background:#00001F;
}
#logo{
padding:10px;
width:149px;
height:38px;
float:left;
background:url(../images/flipkart_india-b1a41241.png);
background-repeat:no-repeat;
background-position:center;
}
#cart{
float:right;
margin:15px 30px 10px 10px;
background:#FFCC00;
padding:8px 20px 8px 20px;
border-radius: 8px;
}
#cart a{
text-decoration:none;
text-align:center;
color:#003399;
text-shadow:#FF0000;
}
#subheader{
width:900px;
background:#003333;
height:50px;
}
#header ul{
padding:10px;
list-style:none;
}
#header ul li{
padding:10px;
float:left;
width:150px;
text-align:center;
}
ul li a{
text-decoration:none;
color: #FFFFFF;
}
#electronics ul{
list-style:none;
}
#electronics ul li{
background:#003333;
color:#fff;
}
#electronics ul li:hover{
background:#555;
}
#header ul li li a{
text-decoration:none;
color:#fff;
}
/* BODY SECTION */
body{
font-family:Arial, Helvetica, sans-serif;
}
#content{
padding: 0px;
width:900px;
position:relative;
height:auto;
}
#main{
margin:10px;
width:670px;
float:left;
height:auto;
}
#slider_header{
width:670px;
height:80px;
margin: 10px;
}
#slider1{
margin:0px 10px 10px 10px;
width:671px;
height:300px;
overflow:hidden;
background-image:url(../images/small-loader.gif);
background-repeat:no-repeat;
background-position:center;
}
#slider1 img{
display: none;
}
#ads_container{
clear:both;
width:170px;
background-color:#CCCCCC;
border:1;
border-color:#000000;
position:absolute;
top:0px;
right:0px;
margin:10px;
padding:10px;
height:auto;
}
.ads:hover{
border:1px solid #000000;
}
Remove the absolute position on your div, and put a float on instead. Also remove the clear:both;
#ads_container {
width: 170px;
background-color: #CCCCCC;
border-color: #000000;
top: 0px;
right: 0px;
margin: 10px;
padding: 10px;
height: auto;
float: right;
}
I'm trying to horizontally center an image. However it does not move from the left side of the page. This answer does not work in my case. What am I doing wrong?
#container {
width: 100%;
border: 2px yellow dashed;
height: 100px;
}
#profile-image img{
margin-left: auto;
margin-right: auto;
border: 2px orange solid;
}
mypage:
<div id="container">
<div id="profile-image">
<p><img src="<?php echo $data['profile_image_url'];?>" alt="me"></p>
</div>
to make any div or anything horizontally at center , common css approach will be,lets have a width and declare margin:0 auto;
#profile-image{
width:400px;
margin:0 auto;
}
Try this: http://jsfiddle.net/rua4d/2/
#container {
width: 300px;
border: 2px yellow dashed;
height: 100px;
display:table-cell;
position:relative;
vertical-align:middle;
}
#profile-image img{
margin-left: auto;
margin-right: auto;
border: 2px orange solid;
display:block;
position:relative;
vertical-align:middle;
text-align:center;
width:50px;
}
You just need to add display:block to your image's style. Images are inline elements, and inline elements ignore margins.
why cant this work?
#profile-image p { text-align: center; }
#profile-image img { display: inline; }
that way you won't need to specify the width.. if you want margins to work together with the text-align: center you would need inline-block instead:
#profile-image p { text-align: center; }
#profile-image img { display: inline-block; }
This a joomla template I created from scratch.
It has some php, like all things in joomla, but please use css and html in your answers because php is not one of my strong skills.
The problem is the main menu.
In all the other browsers, the three elements in the header are pushing the menu out of the header div, putting it just below the bottom border where I want it to be.
My header height is on auto. I don't want to make it fixed and I don't want to use positioning.
I want to stick it under the header.
The ul li are dynamically created by joomla and I am using rtl direction.
This image shows the IE problem
And this image is how I want it
http://www.flickr.com/photos/60188007#N07/5493611091/
#wrap
{
margin:0 auto;
width:100%;
height:auto;
background-color:#540501;
min-width:1100px;
}
#headr
{
margin:0 auto;
width:99%;
height:106px;
min-width:1000px;
background-color:#2c0300;
border-top:1px solid white;
border-bottom:1px solid white;
border-left:2px solid white;
border-right:2px solid white;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border-radius:20px;
direction:rtl;
}
#logo
{
margin:0 150px;
}
#bunner
{
float:right;
height:60px;
z-index:0;
}
/****************************************************************************
Maine Menu
****************************************************************************/
#maineMenu
{
width:73%;
height:auto;
min-width:900px;
z-index:11;
clear:both;
}
#maineMenu ul
{
list-style-type:none;
margin:0 auto ;
border:none;
}
#maineMenu ul li
{
margin:0 1px 0 0;
min-width:114px;
height:38px;
float:left;
text-align:center;
line-height:37px;
-webkit-transition: all 0.2s ease-out;
}
#maineMenu ul li a
{
text-decoration:none;
color:White;
font-size:1.2em;
border:none;
display:block;
}
#maineMenu ul li a span
{
padding:0 6px;
border:none;
display:block;
background-image:url("../images/buttonTopOnCenter.png");
background-repeat: repeat-x;
background-position:top;
-moz-border-radius:0 0 10px 10px;
-webkit-border-radius:0 0 10px 10px;
-o-border-radius:0 0 10px 10px;
border-radius:0 0 10px 10px;
}
/*************************************************************************************
Menu Hover
*************************************************************************************/
#maineMenu ul li:hover
{
background-color:#b9c119
background-repeat:no-repeat;
position: relative; top: -2px; left: -2px;
}
#maineMenu ul li a:hover
{
text-decoration:none;
color:White;
font-size:1.2em;
border:none;
display:block;
background-color:#b9c119;
background-repeat:no-repeat;
background-position:top right;
position: relative; top: -1px; left: -1px;
}
#maineMenu ul li a span:hover
{
padding:0 6px;
border:none;
display:block;
background-repeat: repeat-x;
background-image:url("../images/buttonTopCenter.png");
-moz-box-shadow: 3px 3px 5px #2C0300;
-webkit-box-shadow: 5px 5px 5px #2C0300;
box-shadow: 5px 5px 5px #2C0300;
position: relative; top: -1px; left: -1px;
}
<div id="wrap">
<div id="headr">
<div id="logo">
<jdoc:include type="modules" name="logo" style="xhtml"/>
</div>
<div id="topMenu">
<jdoc:include type="modules" name="topMenu" style="xhtml"/>
</div>
<div id="bunner">
<jdoc:include type="modules" name="banner" style="xhtml"/>
</div>
<div id="maineMenu">
<jdoc:include type="modules" name="menu" style="xhtml"/>
</div>
</div>
</div>
IE has some issues with z-index: 0; try starting at z-index: 1;,
#bunner
{
float:right;
height:60px;
z-index:1; /*change 0 to 1*/
}