I have a block of divs and I need to align them centered.
I have sucessfully put them side by side, but it´s dinamic and the last one needs to be centered.
Here is my CSS:
.mosaicoBox {
width:170px;
height:165px;
border:1px solid #ccc;
text-align:center;
float:left;
padding:0 10px;
margin-bottom:10px;
display:inline;
margin-right:8px;
}
Here is my HTML:
<center><br /><h3>Sistema TMJ</h3><br />
<div class="mosaicoBox mosaicoBoxOff " align="center">
<img src="../res/mosaico/111/th120x120_111.jpg" class="blank">
<div class="textMosaico">
<span class="orange">Apresentação do Sistema TMJ</span><br />
<span style="font-size:10px;">
<a href="http://www.youtube.com/embed/nwpPDX4RVSk?rel=0&wmode=transparent&autoplay=1"
onclick="return hs.htmlExpand(this, {objectType: 'iframe', width: 480, height: 385,
allowSizeReduction: false, wrapperClassName: 'draggable-header no-footer',
preserveContent: false, objectLoadTime: 'after'})"
class="highslide">assistir</a>
| <a target="_blank" href="../res/mosaico/111/mosaico111.wmv" title="Formato WMV ()">download</a>
</span>
</div>
</div>
<div class="mosaicoBox mosaicoBoxOff " align="center">
<img src="../res/mosaico/112/th120x120_112.jpg" class="blank">
<div class="textMosaico">
<span class="orange">Moldagem do aparelho TMD</span><br />
<span style="font-size:10px;">
<a href="http://www.youtube.com/embed/J6corp_ZNoE?rel=0&wmode=transparent&autoplay=1"
onclick="return hs.htmlExpand(this, {objectType: 'iframe', width: 480, height: 385,
allowSizeReduction: false, wrapperClassName: 'draggable-header no-footer',
preserveContent: false, objectLoadTime: 'after'})"
class="highslide">assistir</a>
| <a target="_blank" href="../res/mosaico/112/mosaico112.wmv" title="Formato WMV ()">download</a>
</span>
</div>
</div>
<div class="mosaicoBox mosaicoBoxOff " align="center">
<img src="../res/mosaico/113/th120x120_113.jpg" class="blank">
<div class="textMosaico">
<span class="orange">Opinião do Dentista</span><br />
<span style="font-size:10px;">
<a href="http://www.youtube.com/embed/bBBbCAjR7iY?rel=0&wmode=transparent&autoplay=1"
onclick="return hs.htmlExpand(this, {objectType: 'iframe', width: 480, height: 385,
allowSizeReduction: false, wrapperClassName: 'draggable-header no-footer',
preserveContent: false, objectLoadTime: 'after'})"
class="highslide">assistir</a>
| <a target="_blank" href="../res/mosaico/113/mosaico113.wmv" title="Formato WMV ()">download</a>
</span>
</div>
</div>
</center>
<div class="separador">
</div>
So the last row is always on the left because of float:left in the css. I have tried to pu all this in another div with text-align:center and the inside divs with display:inline intead of float:left, but it scrambled it. What´s the solution for that? T
hanks for help.
Sorry for my bad english.
you can use inilne-block for this &n text-align:center to it's parent like this:
.parent{text-align:center}
.child{
width:30px;
height:30px;
display:inline-block
}
check this http://jsfiddle.net/sandeep/jXXJQ/2/
Create a wrapper for these three boxes, div which will hold them together.
body {margin:0; padding:0}
.mosaicoWrapper {
margin:0 auto;
width:600px;
}
and in html your code:
<div class="mosaicoWrapper">
<!-- Your code -->
<div class="separador"></div>
That should do the trick :-)
Code: http://jsfiddle.net/jXXJQ/1/
Related
Probably a stupid question, but how can I get an image (in this case a flag) in the same line as some text see image?
My HTML code so far:
<h4>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/c/c3/Flag_of_France.svg/30px-Flag_of_France.svg.png" alt="France" height="13px" width="20px"> FRA
</h4>
Try this:
img {
height:20px;
width:30px;
display: inline;
}
span {
display: inline;
height:20px;
color: blue;
}
<img src="http://www.defendersofthescroll.com/images/franceflag.gif" />
<span>
FRA
</span>
Changes based on your code:
<h4>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/c/c3/Flag_of_France.svg/30px-Flag_of_France.svg.png" alt="France" height="13px" width="20px" display="inline"> <span display="inline">FRA</span>
</h4>
<html>
<body>
<span><h4><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/c/c3/Flag_of_France.svg/30px-Flag_of_France.svg.png" height="10px" width="10px">fra </h4></span>
</body>
</html>
I have made a page that grants me access to a lot of nice websites of the web, so I don't have to type in all the links.
I want to use this page for my site www.x3mismusic.eu for a index of all the songs, but since there is no place for a home button, I'd like to make the full page clickable as a link. I made it so that whenever you use shift+x links will be disabled so that you can click trough the buttons. However even though I put a link on the background it doesn't show it and it also doesn't work.
I tried to put a link (anchor tag) around body, create a second wrap with a link and I even tried to use the JavaScript "onclick" tag in the body, but that didn't work like I wanted, because onclick makes me unable to use the button links I created.
I surfed the web for ages but couldn't find any reason or solution for why the link doesn't work. Can someone please help me with making the background clickable as a link, while being able to still activated the button links?
I am not good at formatting code in here so I'll have a jsfiddle link to the code. Here is the link:
http://jsfiddle.net/e5fm5byn/
<a href="http://jsfiddle.net/e5fm5byn/" target="_blank">because it asked me
to input code</a>
Hie there
you should not have multiple id's with same value
and now coming to your question
<html>
<head>
<style type="text/css">
.disableMenu {
pointer-events:none;
}
.x {
background-color:#000;
color:#600;
padding-left:50px;
padding-right:50px;
padding-top:5px;
padding-bottom:5px;
border:3px solid #600;
text-align:center;
float:left;
}
.x:hover {
background-color:#000;
color:#0a0;
padding-left:50px;
padding-right:50px;
padding-top:5px;
padding-bottom:5px;
border:3px solid #0a0;
text-align:center;
float:left;
}
a {
color:#fff;
text-decoration:none;
}
a:hover {
color:#b89200;
text-decoration:none;
}
body {
background:linear-gradient(to bottom right, #123264, #606);
color:#b89200;
width:100%;
height:100%;
position:absolute;
margin:0;
padding:0;
}
#wrapper {
width:100%;
height:100%;
position:absolute;
left:0%;
top:0%;
margin:0;
padding:0;
}
#wrapper2 {
width:100%;
height:100%;
position:absolute;
left:0%;
top:0%;
margin:0;
padding:0;
}
</style>
</head>
<body onkeypress="IEKeyCap()" onclick="myClickEvent(this)">
<div id="wrapper">
<span class="x">
<b>
youtubeX
</b>
</span>
</a>
<a href="http://www.lunagang.nl" target="_blank" title="lunagang">
<span class="x">
<b>
lunagang
</b>
</span>
</a>
<a href="http://www.facebook.com" target="_blank" title="facebook">
<span class="x">
<b>
facebook
</b>
</span>
</a>
<a href="http://46.21.172.161:2222/CMD_LOGIN" target="_blank" title="direct admin">
<span class="x">
<b>
direct admin
</b>
</span>
</a>
<a href="http://46.21.172.161/squirrelmail/src/login.php" target="_blank" title="squirrelmail">
<span class="x">
<b>
squirrelmail
</b>
</span>
</a>
<a href="http://www.runescape.com" target="_blank" title="runescape">
<span class="x">
<b>
runescape
</b>
</span>
</a>
<a href="http://www.google.com" target="_blank" title="google">
<span class="x">
<b>
google
</b>
</span>
</a>
<a href="http://www.x3mismusic.eu" target="_blank" title="x3mis music">
<span class="x">
<b>
x3mis music
</b>
</span>
</a>
<a href="http://www.game-vortex.eu" target="_blank" title="game-vortex">
<span class="x">
<b>
game-vortex
</b>
</span>
</a>
<a href="http://www.outlook.com" target="_blank" title="outlook">
<span class="x">
<b>
outlook
</b>
</span>
</a>
</div>
</body>
<script type="text/javascript">
function NNKeyCap(thisOne) {
if (thisOne.modifiers & Event.SHIFT_MASK) {
if (thisOne.which == 88) {
var x = document.querySelectorAll(".x");
x.forEach(function(element){
element.classList.add("disableMenu");
});
}
}
}
function IEKeyCap() {
if (window.event.shiftKey) {
if (window.event.keyCode == 88) {
var x = document.querySelector("#wrapper");
x.classList.add("disableMenu");
}
}
}
if (navigator.appName == 'Netscape') {
window.captureEvents(Event.KEYPRESS);
window.onKeyPress = NNKeyCap;
}
function myFunction() {
var x = document.querySelector("#wrapper");
x.classList.remove("disableMenu");
}
function myClickEvent(body)
{
var childDiv = body.querySelector('#wrapper');
var hasClass = childDiv.classList.contains('disableMenu');
if(hasClass)
{
document.location = 'http://www.google.com'; <!-- your background link here -->
}
}
</script>
</html>
here I removed the onkeyup="myFunction()" in body tag as it is removing the disableMenu class which is being added by IEKeyCap
and added myClickEvent which checks if #wrapper has class disableMenu
if it has disableMenu then it will be redirected to the link you assigned to document.location
Hope this helps you
I suspect I'm doing something stupid but I have some hyperlinks styled as images with css but they don't work as links.
Experimental page is at http://cotswoldplayhouse.co.uk/jm3/index.php/what-s-on
and it's the 'Read more' and 'buy tickets' buttons.
The page is built by php but the html looks like this...
<td>
<div class="sg-read-more">
Find out more
</div>
<div class="sg-book-ticket">
Book Ticket
</div>
</td>
The CSS is this....
div.sg-book-ticket {
display:block;
position:absolute;
background:url(images/buy-ticket.png) no-repeat 0 0;
right:15px;
bottom:2px;
width:80px;
height:40px;
text-indent:-9999px;
}
div.sg-book-ticket:hover {
background-position:0 -40px;
}
The images display correctly and the rollover works, but they aren't links.
What have I missed?
I personally would style the link as opposed to the div
div.sg-book-ticket{
position:absolute;
right:15px;
bottom:2px;
}
div.sg-book-ticket > a{
display:block;
background:url(images/buy-ticket.png) no-repeat 0 0;
width:80px;
height:40px;
text-indent:-9999px;
}
div.sg-book-ticket a:hover{
background-position:0 -40px;
}
if you want the whole div to be clickable, use this :
<td>
<a href="#">
<span class="sg-read-more">
</span>
</a>
<a href="http://www.ticketsource.co.uk/event/70577" target="_blank">
<span class="sg-book-ticket">
</span>
</a>
</td>
Can you try the following?:
<a href="<a href="http://www.ticketsource.co.uk/event/70577" target="_blank" alt="book ticket" />
<img src="images/buy-ticket.png" />
</a>
instead of putting the image in the css?
Here i am trying to open and get the contents of one div to target div on-click on a href.
Here i have table where i have hrefs which has the link to div ids, and i have an target div which is empty.
when i click the href links, the linked div contents should open in the target div.
for ex:
for link fea1 i have linked id #m1, when i click the fea1, the #m1 contents should appear in target div.
How can i do this???
here is my code:
HTML:
<!DOCTYPE html>
<html>
<head>
<title>
Example
</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<table border="0">
<tr>
<td>
<hr>
<a href="#m1">
fea1
</a>
<br>
<hr>
<a href="#m2">
fea2
</a>
<br>
<hr>
<a href="#m3">
fea3
</a>
<br>
<hr>
<a href="#m4">
fea4
</a>
<br>
<hr>
<a href="#m5">
fea5
</a>
<br>
<hr>
<a href="#m6">
fea6
</a>
<br>
<hr>
<a href="#m7">
fea7
</a>
<br>
<hr>
<a href="#m8">
fea8
</a>
<br>
<hr>
<a href="#m9">
fea9
</a>
<hr>
</td>
</tr>
</table>
<div class="target">
</div>
<div id="m1">
dasdasdasd
</div>
<div id="m2">
dadasdasdasd
</div>
<div id="m3">
sdasdasds
</div>
<div id="m4">
dasdasdsad
</div>
<div id="m5">
dasdasd
</div>
<div id="m6">
asdasdad
</div>
<div id="m7">
asdasda
</div>
<div id="m8">
dasdasd
</div>
<div id="m9">
dasdasdsgaswa
</div>
</body>
</html>
css:
a{
text-decoration:none;
color:black;
}
.target{
width:50%;
height:200px;
border:solid black 1px;
}
#m1, #m2, #m3, #m4, #m5, #m6, #m7, #m8, #m9{
display:none;
}
You can put all your #m1...#m9 divs into .target and display them based on fragment identifier (hash) using :target pseudo-class. It doesn't move the contents between divs, but I think the effect is close to what you wanted to achieve.
Fiddle
HTML
<div class="target">
<div id="m1">
dasdasdasd m1
</div>
<!-- etc... -->
<div id="m9">
dasdasdsgaswa m9
</div>
</div>
CSS
.target {
width:50%;
height:200px;
border:solid black 1px;
}
.target > div {
display:none;
}
.target > div:target{
display:block;
}
From what I know this will not be possible only with css. Heres a solution how you could make it work with jQuery which is a javascript Library. More about jquery here: http://jquery.com/
Here is a working example : http://jsfiddle.net/uyDbL/
$(document).ready(function(){
$('a').on('click',function(){
var aID = $(this).attr('href');
var elem = $(''+aID).html();
$('.target').html(elem);
});
});
Update 2018 (as this still gets upvoted) here is a plain javascript solution without jQuery
var target = document.querySelector('.target');
[...document.querySelectorAll('table a')].forEach(function(element){
element.addEventListener('click', function(){
target.innerHTML = document.querySelector(element.getAttribute('href')).innerHTML;
});
});
a{
text-decoration:none;
color:black;
}
.target{
width:50%;
height:200px;
border:solid black 1px;
}
#m1, #m2, #m3, #m4, #m5, #m6, #m7, #m8, #m9{
display:none;
}
<table border="0">
<tr>
<td>
<hr>
fea1<br><hr>
fea2<br><hr>
fea3<br><hr>
fea4<br><hr>
fea5<br><hr>
fea6<br><hr>
fea7<br><hr>
fea8<br><hr>
fea9
<hr>
</td>
</tr>
</table>
<div class="target">
</div>
<div id="m1">dasdasdasd</div>
<div id="m2">dadasdasdasd</div>
<div id="m3">sdasdasds</div>
<div id="m4">dasdasdsad</div>
<div id="m5">dasdasd</div>
<div id="m6">asdasdad</div>
<div id="m7">asdasda</div>
<div id="m8">dasdasd</div>
<div id="m9">dasdasdsgaswa</div>
Put for div same name as in href target.
ex: <div name="link"> and <a href="#link">
easy way to do that is like
Demo
havent tried but this might help
$(document).ready(function(){
r=0;s=-1;
$(a).click(function(){
v=$(this).html();
$(a).each(function(){
if($(this).html()==v)
return;
else ++r;
$(div).each(function(){
if(s==r)
$(div).appendTo($(".target"));
++S;
});
});
});
});
Try this code in jquery
$(document).ready(function(){
$("a").click(function(){
var id=$(this).attr('href');
var value=$(id).text();
$(".target").text(value);
});
});
if you use
angularjs
you have just to write the right css in order to frame you div
html code
<div
style="height:51px;width:111px;margin-left:203px;"
ng-click="nextDetail()">
</div>
JS Code(in your controller):
$scope.nextDetail = function()
{
....
}
I am trying to put 2 buttons on a web page, one floated to the left and the other to the right. Both command buttons have multiline styled text within them. Below is my latest attempt. It seems to work on in Firefox, but not even close in IE 8. Any ideas how I can get this to work in both environments? thanks.
CSS:
body {
background-color: green;
}
.idxQuestion {
font-size: 36;
text-align: center;
}
.idxButtons {
margin-top:60px;
margin-left: auto;
margin-right:auto;
width:350px;
}
.buttonchoice1,.buttonchoice2
{
text-align: center;
background:white;
padding: 5px;
}
.buttonchoice1 {
float:left;
border:5px solid red;
}
.buttonchoice2 {
float:right;
border:5px solid blue;
}
.spanchoice1 {
font-size: 30px;
}
.spanchoice2 {
font-size: 10px;
}
HTML:
<div class="idxQuestion">
<h1>Big Question?</h1>
</div>
<div class="idxButtons">
<h:button class="buttonchoice1" onclick="option1?faces-redirect=true" >
<h:outputText escape=false>
<span class="spanchoice1">No</span><br />
<span class="spanchoice2">additional info 1</span>
</h:outputText>
</h:button>
<h:button class="buttonchoice2" onclick="option2?faces-redirect=true" >
<h:outputText>
<span class="spanchoice1">Yes</span><br />
<span class="spanchoice2">additional info 2</span>
</h:outputText>
</h:button>
</div>
Fiddle : http://jsfiddle.net/MF23L/
Replace your code with this piece of code:
<div class="idxButtons">
<button class="buttonchoice1" onclick="option1?faces-redirect=true">
<outputText escape=false>
<span class="spanchoice1">No</span><br />
<span class="spanchoice2">additional info 1</span>
</outputText>
</button>
<button class="buttonchoice2" onclick="option2?faces-redirect=true">
<outputText>
<span class="spanchoice1">Yes</span><br />
<span class="spanchoice2">additional info 2</span>
</outputText>
</button>
</div>
IE isn't recognizing your h:button tag, which you've applied a "buttonchoice1" class to and is the basis of your layout. If you were to wrap those "h:button"s with a div (for example), and move the class from the h:button to the new containing div, it should work. Like this:
<div class="idxButtons">
<div class="buttonchoice1">
<h:button onclick="option1?faces-redirect=true" >
<h:outputText escape=false>
<span class="spanchoice1">No</span><br />
<span class="spanchoice2">additional info 1</span>
</h:outputText>
</h:button>
</div>
....
Why not make images and use <input type="image" alt="No, additional info 1" src="..." /> so it would look the same? I am don't think button is supposed to be fancy.