can't define padding and margins in external css sheet - php

I'm trying to define some css styling to an < a > element, in particular, padding and margins. I've noticed that when I'm trying to define it in-line, it's working, but when I try to use a class selector in an external style sheet, for some reason it is not working. The weird thing is that other attributes (like height), does work in the external file.
The relevant php code:
<div id='navbar_line'>
<nav class="home_navbar">
<div class="container">
<div id="navbar" class="collapse navbar-collapse" style='padding:0'>
<ul class="nav navbar-nav home_nav">
<?php
// Create the top navigation list by listing the children of the homepage.
// If the section we are in is the current (identified by $page->rootParent)
// then note it with <a class='on'> so we can style it differently in our CSS.
$homepage = $pages->get( "/" );
$children = $homepage->children;
$reversed = $children->reverse();
foreach ($reversed as $child) {
echo "<li class='home_navbar_item'>";
echo "<a href='{$child->url}'>";
echo "<div class='navbar_logo'>";
echo "<img src='{$child->page_logo->url}' alt='{$child->title}' height='30' width='30'>";
echo "</div>";
echo "</a>";
echo "</li>";
}
echo "<li class='home_navbar_item'> <a href='{$homepage->url}'>";
echo "<img src='{$meta_data->Logo->url}' alt='{$homepage->title}' height='30' width='30'>";
echo "</a>";
echo "</li>";
?>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
</div>
The css code:
#lower_part span{
padding:0;
margin:0;
white-space: pre;
}
#navbar_line{
background-color: #04619c;
height: 137px;
margin: auto;
}
#navbar{
background-color: #04619c;
}
.home_navbar_item a {
height: 300px;
padding:0;
margin:0;
}
.navbar_logo{
height: 50px;
width: 50px;
background-color: white;
/*border-radius: 50%;*/
}
.carousel_image{
width:100%;
}
.hebrew_text{
text-align: right;
}
#scrollable_body{
height: 100px;
margin:0;
padding:0;
}
.scrollable_content{
padding:0;
overflow: scroll; overflow-x:hidden;
height: 500px;
/*-webkit-overflow-scrolling: touch;*/
}
span{
padding:4em 0 0 0;
display:inline-block;
}
hr {
border:none;
border-top:1px dotted #f00;
color:blue;
background-color:#fff;
height:1px;
width:50%;
}

Seems you just can't override previous defined padding & margin, while you doing that inline, inline styles have bigger priority and applies.
Try to read this article, it can helps to understand a problem https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity

Related

Rounded corner using border radius for dynamically generated li

I'm having trouble rounding just one corner of my ul list. The last one specifically. Right now, all the corners on the bottom are rounded. Here is my code php code:
<div class="container">
<?php
$pagination = $products->pagination();?>
<?php foreach($pagination->range(10)as $r): ?>
<div class="paginator">
<ul>
<li><a<?php if($pagination->page() == $r) echo ' ' ?> href="<?php echo $pagination->pageURL($r) ?>"><?php echo $r ?></a></li>
</ul>
</div>
<?php endforeach ?>
and my css:
.paginator a:active {
background-color: #2A4143;
color: #fff;
}
.paginator {
margin-left: auto !important;
margin-right: auto !important;
text-align: center;
display: inline-block;
}
.paginator ul {
margin-right: -4px;
}
/*.paginator ul{*/
/* width: 100%;*/
/* margin-left: auto;*/
/* margin-right: auto;*/
/* !*position: absolute;*!*/
/* !*bottom: 0;*!*/
/* !*left:0;*!*/
/* !*right:0;*!*/
/*}*/
.paginator ul li a {
/*float: left;*/
padding: 10px;
font-size: 13px;
font-weight: 600;
height: 28px;
width: 28px;
background-color: #F5F5F5;
border: 1px solid #2A4143;
/*border-right-width: 0;*/
margin-right:-1px;
margin-bottom:-1px;
display: inline;
/*display: inline;*/
/*display: block;*/
/*max-height: 100px;*/
/*position: absolute;*/
}
.paginator li:last-child a {
border-bottom-right-radius: 10px;
}
I saw a few solutions on Stack Overflow and elsewhere, but it doesn't really handle a dynamically generated list.
figured it out.
I moved the class on top of the php.
<div class="container">
<?php
$pagination = $products->pagination(); ?>
<div class="paginator">
<ul>
<?php foreach ($pagination->range(10) as $r): ?>
<li><a<?php if ($pagination->page() == $r) echo ' ' ?>
href="<?php echo $pagination->pageURL($r) ?>"><?php echo $r ?></a></li>
<?php endforeach ?>
</ul>
</div>
</div>
and changed the CSS like so:
.paginator ul {
margin-right: -4px;
display: flex;
}

Echo items in a list and align them

I have a php to echo three variable fields :
<li>
<mark> <?php while( $toprow2 = sqlsrv_fetch_array( $stmt3) ) {
echo $toprow2['overallRank'] ." ".$toprow2['EmployeeName'] ." ".$toprow2['Total_points_Rewarded']."<br/>";} ?>
</mark>
</li>
Among these three variables of the list,I want to align the first field "overallRank " to left ,"EmployeeName " to centre and "Total_points_Rewarded" to extreme right.
Below is the code I tried for the first field:
<li>
<mark> <?php while( $toprow2 = sqlsrv_fetch_array( $stmt3) ) {
echo "<div style = "text-align=left" ."$toprow2['overallRank'] "</div>"." ".$toprow2['EmployeeName'] ." ".$toprow2['Total_points_Rewarded']."<br/>";} ?>
</mark>
</li>
when I use three divs :
echo "<div style ='text-align:left'>" . $toprow2['overallRank'] . "</div><div style ='text-align:centre'>" . $toprow2['EmployeeName'] . "</div><div style ='text-align:right'>" . $toprow2['Total_points_Rewarded'] . "</div>";
I am not able to align them :Current scenario :
the first block is the rank,then name and last points - the three fields that I am trying to echo here.
css used for above situation:
li mark {
display: inline-block;
justify-content: space-between;
}
li mark div {
display: block;
margin: 4px;
padding: 5px;
min-height: 100px;
border: 1px solid #eebb55;
border-radius: 7pt;
background: grey;
}
#Abhay has a great solution :css aint working here,though
current situation:
Use flex:
echo "<div class='parent-div'><div class='rank'>" . $toprow2['overallRank'] . "</div><div class='name'>" . $toprow2['EmployeeName'] . "</div><div class='points'>" . $toprow2['Total_points_Rewarded'] . "</div></div>";
Your CSS:
.parent-div{
display: -webkit-flex; /* Safari */
display: flex;
}
.rank,.name,.points{
width:33%;
}
.name{
text-align: center;
}
.points{
text-align: right;
}
Small working ex:
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<style>
.parent-div{
display: -webkit-flex; /* Safari */
display: flex;
}
.rank,.name,.points{
width:33%;
}
.name{
text-align: center;
}
.points{
text-align: right;
}
</style>
</head>
<body>
<div class="parent-div">
<div class='rank'>Rank</div>
<div class='name'>Name</div>
<div class='points'>Points</div>
</div>
<div class="parent-div">
<div class='rank'>Rank</div>
<div class='name'>Name</div>
<div class='points'>Points</div>
</div>
<div class="parent-div">
<div class='rank'>Rank</div>
<div class='name'>Name</div>
<div class='points'>Points</div>
</div>
</body>
</html>
If continuing with span :
echo "<div class='parent-div'><span class='rank'>" . $toprow2['overallRank'] . "</span><span class='name'>" . $toprow2['EmployeeName'] . "</span><span class='points'>" . $toprow2['Total_points_Rewarded'] . "</span></div>";
Try this CSS:
.parent-div{
display: -webkit-flex; /* Safari */
display: flex;
}
.rank,.name,.points{
display:block;
width:33%;
}
.name{
text-align: center;
}
.points{
text-align: right;
}
Please mind that I have given class: parent-div to all three spans container div.
I hope it helps
Why don't you use
li mark {
display: inline; /* don't use inline-block */
justify-content: space-between;
}
li mark div {
float: left; /* here you put the float so it can be after the first li mark */
display: block;
margin: 4px;
padding: 5px;
min-height: 100px;
border: 1px solid #eebb55;
border-radius: 7pt;
background: grey;
}
li mark div:first-child {
float: left; /* it will put your first div in left side */
}
li mark div:last-child {
float: right; /* it will be in the right side */
}
Also why not remove a width. For example instead being without it in the classes above, this means the width is 100% you could adjust it to width: 50% to half.

Float left not working

I'm currently working on a "webshop" kind of project. I am creating a product panel with a
float:left; property but when I loop the products they are not coming next to each other but underneath the previous one.. What am I missing?
Code:
$web_string = "
<div class='product'>
<div class='image'>
<img class='image' src='iphone.jpg' alt='iPhone' height='100%' width='100%' />
</div>
<div class='under'>
<div class='info'>
<ul>
<li>iPhone</li>
<li>iOS</li>
<li>16 GB</li>
<li>Black & White</li>
</ul>
<a href='#'>more info...</a>
</div>
<div class='extra'>
<p>price: 588</p>
<button>put in cart!</button>
</div>
<div>
</div>";
CSS:
#wrapper{
width: 100%;
height:100%;
background-color: blue;
}
.product
{
float:left;
width:250px;
height:250px;
background-color:red;
}
.onder
{
height:50%;
}
.afbeelding
{
background-color: green;
}
.info
{
background-color:yellow;
float:left;
width:50%;
height:100%;
}
.extra
{
background-color: purple;
float:right;
width:50%;
height:100%;
}
PHP Loop:
<?
echo $web_string;
for($i = 0; $i < 4; $i++)
{
echo $web_string;
if($i == 2)
{
echo "Hello World";
}
}
?>
EDIT: Changed ID's to Classes
You're using CSS ID selector which can be used to point only ONE element. So the float property is applied only on the first one. Use class instead : <div class='product'> and then in your CSS : .product { float: left; }
Same thing for "image" and "under"
Here is a jfiddle fix:
link
Had to add float: left; on image and under ID too
#image {
float: left;
}
#under {
float: left;
}
Let me know if this is what you needed

Centering my css3 menu of changing widths...?

I have a css menu which has a width of 400 for non-Admins... and a width of 500 for Admins. If I set the UL width to 500, the menu centers fine and nicely for Admins. But for non-admins, whose mneu is really only 400 wide... it's off-kilter.
So I removed the width attribute from the UL to try and remove this and then it lost centering altogether; the whole menu is now stuck to the left side of the container.
Anyone have a simple idea for how to make it always centered? Site is here:
http://www.runic-paradise.com/
ul.menu{
height: 40px;
list-style: none outside none;
margin: 0 auto;
/*width: 500px;*/
}
/*li{
width:100px;
height:50px;
float:left;
color:#191919;
text-align:center;
overflow:hidden;
}*/
a.menu{
color:#FFF;
text-decoration:none;
}
p.menu{
padding-top: 10px;
padding-right: 5px;
padding-left: 5px;
}
.subtext{
padding-top: 10px;
}
ul.menu li{
width: 100px;
height: 40px;
float: left;
color: #191919;
text-align: center;
overflow: hidden;
}
/*Menu Color Classes*/
.green{
background:#6AA63B url('/img/menu/green-item-bg.jpg') top left no-repeat;
}
.yellow{
background:#FBC700 url('/img/menu/yellow-item-bg.jpg') top left no-repeat;
}
.red{
background:#D52100 url('/img/menu/red-item-bg.jpg') top left no-repeat;
}
.purple{
background:#5122B4 url('/img/menu/purple-item-bg.jpg') top left no-repeat;
}
.blue{
background:#0292C0 url('/img/menu/blue-item-bg.jpg') top left no-repeat;
}
<ul class="menu">
<li class="green">
<p class="menu">Home</p>
<p class="subtext">The front page</p>
</li>
<li class="yellow">
<p class="menu">-</p>
<p class="subtext">More info</p>
</li>
<li class="red">
<p class="menu">Forums</p>
<p class="subtext">Get in touch</p>
</li>
<li class="blue">
<p class="menu">-</p>
<p class="subtext">Send us your stuff!</p>
</li>
<?php
if ($user->data['group_id'] == 5)
{
echo ' <li class="purple">
<p class="menu">Admin</p><p class="subtext">Legal things</p>
</li>';
}
?>
</ul>
Your CSS sets the ul.menu width to 400px. If the user is admin, the php script adds another 100px wide li to ul.menu. When this happens, you have to set the ul.menu width to 500px. If you do this, the css rule margin:0px auto; will handle the centering as expected.
A simple jQuery fix would be something like this:
<script>
$(document).ready(function() {
var menu=$('ul.menu');
if(menu.find('li')>4) {
//if there are more then 4 menu items, reset menu width to 500px
menu.css('width','500px');
}
});
</script>
Use max-width:500px;for UL.Demo for these http://jsfiddle.net/dhanith/ZMB93/
Can you please try this,
In animated-menu.css (demo url: http://www.runic-paradise.com/), Change margin style as like below
ul.menu {
height: 40px;
list-style: none outside none;
margin: auto 25%;
}

jcarousel is not scrolling through images

i have a jcarousel gallery of images
but the jcarousel is not working at all it's not scrolling through images at all
this is my code :
<ul id="mycarousel" class="jcarousel-skin-tango">
<?php foreach ($images as $image_item) : ?>
<li><img src="<?php echo $image_item['Path']; ?>"/></li>
<?php endforeach; ?>
</ul>
and this is my css :
.jcarousel-skin-tango .jcarousel-container {
width:500px;
height:250px;
background: none;
border: none;
}
.jcarousel-skin-tango .jcarousel-container-horizontal {
height:250px;
padding: 20px 40px;
}
.jcarousel-skin-tango .jcarousel-clip-horizontal {
width: 500px;
height: 250px;
}
.jcarousel-skin-tango .jcarousel-item {
width: 500px;
height: 250px;
}
.jcarousel-skin-tango .jcarousel-item-horizontal {
margin-left: 0;
margin-right: 10px;
}
and there is my js :
$(document).ready(function(){
$('#mycarousel').jcarousel({wrap:'circular'});
});
Your code is almost correct — you just need to add "auto: 1" (or some other non-zero number of seconds) and it'll start auto-scrolling. If you don't want auto-scroll, you need to specify the "buttonNextHTML" and "buttonPrevHTML" parameters to get buttons.

Categories