w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
'
How do I center an image inside a div given my code situation?
You cannot vertical-align block elements. If you know the height of the image you could put an equal top and bottom margin on .img_plc or an equal top and bottom padding on `.box.' As you've said it's variable height, then you can use display: table-cell for .box with vertical-align: middle;

Categories : CSS

How to resize the box but still put text inside it at center?
Try applying: (working jsFiddle) .title h2 { margin:0px; line-height:100px; /* change to fit your needs */ } vertical-align is not the best approach in this case.. UPDATE: Use this jsFiddle instead, it uses vertical-align as you wanted and you don't need to apply the line-height of h2.. the secret is making the parent display:table; and the child display:table-cell: .title { display: table; /* Here's the trick */ border-radius: 12px; border: 1px solid; height: 100px; width:100%; } .title h2 { display:table-cell; /* Here's the trick */ height:100%; vertical-align:middle; }

Categories : HTML

Trying to center a rotated text inside a floated div
I don't get your question, but i think you just want to align your heading h3 to be centrally aligned. One way of doing this is using css property line-height #child { float:right; height:100px; width:70px; clear:right; background-color: orange; line-height: 50px; /*text-align: center;*/ } you can change it as per your requirement. FIDDLE: http://jsfiddle.net/w5K4j/31/

Categories : Jquery

jQuery: Center text inside progress bar
You'll need a line-height to get it centered vertically: line-height: 35px; FIDDLE

Categories : Jquery

Getting the text inside a div to be dead center (vertical and horizontal)
If it is only going to be one line of text you can do this: #alertText { line-height: 58px; text-align: center; } If you going to have more lines of text you might need to do it some other way. Possible with position.

Categories : CSS

Vertically center text inside position: fixed
You can change the line-height of the anchor tag. #click-hear a{ background-image: url('...'); display: block; ****line-height:50px; height: 60px; width: 200px; margin: 0 auto; margin-top: 20px; text-align: center; } Just play with the line height until it's centered. It should give you the desired result. You could also add padding, but that would mess up the background image.

Categories : HTML

Javascript / REGEX: Delete a specific Text (word) starting with a specific letter inside a String with words separated by spaces
How about: str.replace(/sS+/ig,"") Explanation: NODE EXPLANATION ----------------------------------------------------------------------  the boundary between a word char (w) and something that is not a word char ---------------------------------------------------------------------- s 's' ---------------------------------------------------------------------- S+ non-whitespace (all but , , , f, and " ") (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- i is for case-insensitive g is for global

Categories : Javascript

Choosing apropriate layout for this specific situation
You seem to have the design you need. Break down each section and apply the required layout to achieve that section. Each section should be a self contained component. So to my mind, start by modelling the data. You need a Document model, which contains a list of Chapters, which contains a list of Pages, which is made up of a list of Titles, which is is made up of a list of questions. I would then provide a view for each level of the model. This will allow you to concentrate on the individual needs of each view, in isolation and reuse the code logic. It also means if you need to make changes, they will be more easy to make and reflected through the entire program You seem to have the right idea for the Document/Chapters, being laid out within tabs. I'd follow through. Each Page wou

Categories : Java

Faster IO giving slower results in this specific situation
You do not have enough data on the SPOJ timings. The codechef timings all look too close to call to me. Any timing difference between one .readline() call and one next() call are going to come down to differences in swap availability, other processes running on the machine, I/O flushes, etc. In other words, not to any actual performance differences between the two approaches. You'll have to do your own timings, on your own machine, against thousands of runs to be able to figure out if one is actually faster than the other.

Categories : Python

Bold a specific text inside a contenteditable div
Here is a sample. An editable div is not a good idea though. Try to change this. A textarea maybe is better... http://jsfiddle.net/blackjim/h9dck/5/ function makeBold(match, p1, p2, p3, offset, string) { return p1+'<b>' + p2 + '</b>'+p3; }; $('#message').keyup(function (e) { var $this = $(this); //detect space if (e.keyCode == 32) { var innerHtml = $this.html(); innerHtml = innerHtml.replace(/(.*[s|($nbsp;)])(#w+)(.*)/g, makeBold); if(innerHtml !== $this.html()){ $this.html(innerHtml) .focus(); } } });

Categories : Javascript

how to center text inside donut chart embedded in combination chart
You can use renderer to add custom text on your chart. Then you can add events using element.on(). See live example: http://jsfiddle.net/sJfuA/2/ $('#container').highcharts({ chart: { events: { load: function() { var chart = this, rend = chart.renderer, pie = chart.series[4], left = chart.plotLeft + pie.center[0], top = chart.plotTop + pie.center[1], text = rend.text("text", left, top).attr({ 'text-anchor': 'middle'}).add(); text.on("mouseover", function() { alert("hover!"); }); } } }, ... });

Categories : Highcharts

Getting text to display to the left and right of a text-align: center
Simply float all the divs to the left. They will display in order. <style> .my-dvis { float:left; width:33.33%; margin:0; padding:0; border:none; } </style> <div class="my-divs"></div> <div class="my-divs"></div> <div class="my-divs"></div>

Categories : HTML

Duplicate span text into a text field in a form
You could always do the following function calculateSum() { var sum=0; $(":text").each(function() { if(!isNaN(this.value) && this.value.length!=0 { sum+=parseFloat(this.value); } }); $("#sum").html(sum.toFixed(0)); $("#myTextField").val(sum.toFixed(0)); //adding to text field }

Categories : Javascript

CSS animation from center to specific location
I removed the left from the animation and added padding and box-sizing to .title: .title { position: absolute; min-width: 100%; text-align: center; width: auto; padding: 0 50px; box-sizing: border-box; } .anim { -webkit-animation: translate-title 2s linear; -webkit-animation-fill-mode: forwards; animation: translate-title 2s linear; animation-fill-mode: forwards; } @-webkit-keyframes translate-title { 0% { min-width: 100%; } 100% { min-width: 0; } } @keyframes translate-title { 0% { min-width: 100%; } 100% { min-width: 0; } } FIDDLE

Categories : HTML

How to center element inside of a div
just remove this: body { width: 960px; margin: 0 auto; } use this: HTML <div class="content">test</div> <div class="SideBarFirst"> <div>not working for center</div> </div> CSS: .content {width:500px; float : left;} .SideBarFirst {width:460px; float : right;} .SideBarFirst div { width: 40px; margin: 0 auto; } See This Fiddle

Categories : CSS

Center Elements Inside of a Div
Whenever I face any floated container to center horizontally I use the followings. Try wrapping your markup (which needs to be centered; the div in your case) with these: <div class="center_outer"> <div class="center_inner"> <!-- Put your contents here (which needs to be centered) --> </div> </div> CSS: .center_outer { position: relative; left: 50%; float: left; } .center_inner { position: relative; left: -50%; } Check: http://jsfiddle.net/jduDD/1/ (I have removed the width style)

Categories : CSS

Center div inside header
You need to specify a width for #logo. If you don't want to do that then you can set text-align:center for header. http://jsfiddle.net/6kWfU/

Categories : CSS

How to duplicate Console text to text file?
Create a class derived from TextWriter Allow it to takes as many instances of you want (say writers) Implement TextWriter in your derived class to output the data to every instance of writers Create an instance of your derived class (eg: new Foo(Console.Out, File.CreateText("Foo"))) Console.SetOut(the_instance_of_your_textwriter) PROFIT!!!

Categories : C#

jQuery center specific table columns
Try this: $('tr').each(function() { var tds = $(this).find('td'); var len = tds.length; for (var i = 1; i < len; i++) { $(tds[i]).css('text-align', 'center'); } });

Categories : Jquery

How to center position of specific TreeView node?
The only way I can find to scroll a TreeView is to send it a WM_VSCROLL with a value of SB_LINEDOWN/SB_LINEUP. For some reason the control does not seem to respond to a scroll value of SB_THUMBPOSITION, like for instance a rich edit does. For this reason, the below try, centers a node more or less by sending the control a bunch of line scroll messages. Try and see for yourself if it suits your needs. var DR, CR: TRect; ScrollPx, ScrollLines, i: Integer; begin if Assigned(TreeView1.Selected) then begin // calculate how many *pixels* should we scroll DR := TreeView1.Selected.DisplayRect(False); CR := TreeView1.ClientRect; ScrollPx := - Round((CR.Bottom / 2) - DR.Top - ((DR.Bottom - DR.Top) / 2)); // how many lines does it correspond to ScrollLines := ScrollPx

Categories : Delphi

Vertically center three divs, one inside another
You could just modify layout display of html & body, and takes advantage of tables layout specifities: example fiddle used for some similar question (remove divs unwanted ;) ): http://jsfiddle.net/GCyrillus/jGtAv/3/ html { text-align:center; display:table; width:100%; height:100%; } body { display:table-cell; vertical-align:middle; }

Categories : HTML

how to horizontally center-crop div inside other div
if the width of your poster_row isn't about to change add: .poster_row { text-align: center; margin: auto; display: inline-block; white-space:nowrap; overflow:hidden; border: dotted; border-color: blue; position:absolute; left: 50%; margin-left: -525px; width: 1050px; } otherwise you have to calculate the width and margin-left with Js

Categories : CSS

How to center fillPatternImage inside wedge?
You can use trigonometry to calculate the width/height of the triangle portion of the wedge: In this illustration, the red line is width and the yellow line is height. function calcWedgeDimensions(x,y,radius,angleDeg){ var angleRad=angleDeg*Math.PI/180; var r=-(angleRad/2+Math.PI/2); var x1=x+radius*Math.cos(-angleRad/2-Math.PI/2); var y1=y+radius*Math.sin(r); var x2=x+radius*Math.cos(+angleRad/2-Math.PI/2); return({width:x2-x1,height:y-y1}); } If needed, you can use context.measureText to get the width of your text to center it: function calcTextWidth(text,font){ context.font = font; var metrics = context.measureText(text); return(metrics.width); }

Categories : Javascript

Raphael: How to center circle inside div
I suspect what you're wanting to achieve can be obtained by changing the rotate to rotate(180, 100, 100) so that you're rotating about the centre rather than some other point. I.e. var my_arc = archtype.path().attr({ "stroke": "#f00", "stroke-width": 2, arc: [100, 100, amount, 100, 100] }).rotate(180, 100, 100);

Categories : Javascript

css center div inside div generated by jquery
Here you got updated jsFiddle: http://jsfiddle.net/6rgMj/1/ I've add z-index property to .overlay-text-inside-container and this property bring that element above #overlay-background. I've also change onclick attribute in your a element, which is a bad habitat. You should try to avoid using JavaScript events in HTML attributes, because this can cause problems with code maintaining in the future. I'm not sure if this is all you ask, but if not I'll update my answer.

Categories : Jquery

Center div horizontally and vertically inside another div
Add width and height to .btn, next add position:absolute; left:50%; top:50%; and the last - margin: -50% .btn-height 0 0 -50% .btn-width Something like that .btn.small { width:140px; height:36px; margin:-18px 0 0 -70px; position:absolute; left:50%; top:50%; } And one more small advice: instead of .btn:hover in this case better use .col-1-3:hover .btn or wrap img and .btn in another div, for example .img-box, and set the rule .img-box:hover .btn

Categories : HTML

Center button inside bootstrap
Assuming you mean horizontally centered, you can add text-align:center to the pre tag. <pre style="text-align: center"> <button class="btn">Button</button> </pre>

Categories : Twitter

JQuery removing specific duplicate row
Here's an adapted version of that code you can use: var seen = {}; $('tbody').each(function() { var elmt = {txt: $(this).text(), ref: this}; if (seen[elmt.txt]) { if ($(seen[elmt.txt].ref).hasClass('off')) { $(seen[elmt.txt].ref).remove(); seen[elmt.txt].ref = this; } else { $(this).remove(); } } else seen[elmt.txt] = elmt; }); Demo here. It will search for all tbody with repeated text() content. If it finds a repeated one, it will preferrably remove the one with the off class. If none have got it, it will remove the last one found. Examples: The first tbody will prevail: <table> <tbody class="blu"><tr><td>somedata</td></tr></tbody> <tbody class="off"><tr

Categories : Jquery

Scaling objects from a center point by a specific number
It seems that you want to scale the object so that it's new size is (say) 3.6 units larger than it's old size. In that case, the code would be the same except for scale = (old_size + 3.6) / old_size; You still need to scale each vector by the same amount, in order to preserve the overall shape of the object.

Categories : C++

How to put content inside td to be horizontal at center of cell?
try <td style='margin: 0 auto; align:center;'> or wrap it in a div as such <td><div style='margin: 0 auto; align:center; width: 100%;'><span style="margin-left: auto; margin-right: auto;">{{r['username']}}</span></div></td> The div would probably be best because I think that the width property also needs to be set.

Categories : CSS

How to center the message inside an alert box in JavaScript?
Here is a very simple solution using custom code. Just click the message box to close it. The alert is no longer blocking, instead it is callback oriented. The message box is also always at the center of the window. http://jsfiddle.net/BUmc4/2/ JAVASCRIPT (function() { window.alert = function(html, callback) { var messagebox = document.getElementById("messagebox"); messagebox.style.display = "block"; var message = document.getElementById("message"); message.innerHTML = html; messagebox.attributes.callback = callback; }; }()); alert("Hello World", function() { alert("How are you?"); }); HTML <div>Can you see me?</div> <div>Can you see me?</div> <div>Can you see me?</div&g

Categories : Javascript

Center align divs inside parent div
To center the four DIVs set them to .cellContainer { float: none; display: inline-block; } and center the navbar contents #navBar { text-align: center; }

Categories : HTML

how can I center child div inside parent div with margins?
You can define a fixed width, and set the left and right side margin value of auto.Like this: .content { width: 940px; margin-left: auto; margin-right: atuo; } div.content_inner { background-color: white; -moz-box-shadow: 1px 5px 10px #000; -webkit-box-shadow: 1px 5px 10px #000; box-shadow: 1px 5px 10px #000; /* margin-left: 10%; margin-right: 10%;*/ /*please delete*/ }

Categories : CSS

How to center multiple divs inside a container in CSS
You could apply the style text-align:center; to your container and display your .blocks as inline-block elements: .container { width: 70%; background: #eee; margin: 10px auto; position: relative; text-align:center; } .block { background: green; height: 100px; width: 100px; display:inline-block; margin: 10px; } <div class="container"> <div class="block">1. name of the company</div><!-- --><div class="block">2. name of the company</div><!-- --><div class="block">3. name of the company</div><!-- --><div class="block">4. name of the company</div><!-- --><div class="block">5. name of the company</div><!-- --><div class="block">6. name

Categories : HTML

Vertically, Center-fit an image inside a Table row '
<style> .mystyle { border:2px solid #cccccc; background: url(bar.png) no-repeat center left; filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffe732', endColorstr='#ffffff',GradientType=1 ); /* IE6-8 */ width: 247px; background-position:center; } </style>

Categories : HTML

How to center the content inside a linear layout?
android:layout_gravity is used for itSelf of layout use android:gravity="center" for childs of your LinearLayout so your code should be <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:gravity="center" android:layout_weight="1" >

Categories : Android

select lines with duplicate columns by a specific value
Try the below(assuming field 4 is >= 0 throughout) Array b is used to track the highest value in field 4 for unique values in field 1. Array a (keyed by field 1) contains the corresponding record. As each record is processed, the record is added to array a and field 4 is added to array b if 1. a value is encountered in field 1 for the first time or 2. the value in field 4 exceeds the existing value in b for the value in field 1. Finally, array a is printed out. awk '$4 > b[$1] {a[$1] = $0; b[$1] = $4} END{for (x in a) {print a[x]}}'

Categories : Regex

delete duplicate tuples except for one specific tuple
You could try with this (untested)... ;WITH temp AS ( SELECT [from_id], [to_id], [object_id] = min([object_id]) FROM table group by [from_id],[to_id] having count(*) > 1) SELECT t2.[from_id], t2.[to_id], t.[object_id] FROM table t join temp t2 on t2.[from_id] = t.[from_id] AND t2.[to_id] = t.[to_id] AND t2.[object_id] != t.[object_id] EDIT: CTE temp will yield all distinct from/to groupings with min object_id, one you would like to keep. SELECT [from_id], [to_id], [object_id] = min([object_id]) FROM table group by [from_id],[to_id] having count(*) > 1 There are other pairs you would like to remove, and these are same from/to pairs, but with different object_id. Last select should output those records exactly.

Categories : Database

Remove specific tags if are inside specific tag
Using Nokogiri: require 'nokogiri' doc = Nokogiri::HTML::Document.parse <<-_HTML_ <p>Hello</p> <table> <tr> <td><p>Text example <br>continues...</p></td> <td><p>Text example <br>continues...</p></td> <td><p>Text example <br>continues...</p></td> <td><p>Text example <br>continues...</p></td> </tr> </table> <p>Bye<br></p> <p>Bye<br></p> _HTML_ doc.xpath("//table/tr/td/p").each do |el| el.replace(el.text) end puts doc.to_html Output: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html><body>

Categories : HTML

How do center text to a text area?
You can add padding to your .labels css property, in your case, around 6px should do it! td.labels { width: 89px; display: inline-block; text-align: right; padding-top: 6px; vertical-align: middle; } Also, you have way too many elements for something that could be so simple: DEMO: http://jsfiddle.net/shannonhochkins/d4rLD/2/

Categories : CSS



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.