2016-09-09 9 views
0

私の文章は「賞金を得るチャンスのためにFacebookのように」と言いたい。 「Facebook」という言葉をリンクしたいが、下線は付けない。私はまた、テキストとリンクを1行にしたい。 Here is what the output looks like nowテキストを修正して1行に表示するにはどうすればよいですか?

ここは私のコードです。

function popupWin() { 
text = "<html>\n<head>\n<title>Pop Window</title>\n<body>\n"; 
text += "<center>\n<br>"; 
text += "<h4>Like us on </h4>" + "<a href='myLink' target='_blank'><h4>Facebook</h4></a>" + " <h4>and win a prize</h4>"; 
text += "</center>\n</body>\n</html>\n"; 
setTimeout('windowProp(text)', 1000); 
} 
function windowProp(text) { 
newWindow = window.open('','newWin','width=300,height=200'); 
newWindow.document.write(text); 
} 
+2

それぞれ '

'はブロックです。あなたは3つを必要としません、あなたはおそらく1つのコンテンツが内部にあります。 – vlaz

+0

そして、下線を引かないようにするには、 ''に' text-decoration:none; 'をつけてください。 – neilsimp1

答えて

2
function popupWin() { 
text = "<html>\n<head>\n<title>Pop Window</title>\n<body>\n"; 
text += "<center>\n<br>"; 
text += "<h4>Like us on " + "<a href='myLink' target='_blank' style='text-decoration: none;'>Facebook</a>" + " and win a prize</h4>"; 
text += "</center>\n</body>\n</html>\n"; 
setTimeout('windowProp(text)', 1000); 
} 
function windowProp(text) { 
newWindow = window.open('','newWin','width=300,height=200'); 
newWindow.document.write(text); 
} 

popupWin(); 

一つ<h4>タグは、テキスト全体のH4を行うのに十分です。あなたはそれを倍加する必要はありません。

Facebookのリンクは責任を負いませんCSS text-decoration: noneインラインHTMLの属性styleです。

0
function popupWin() { 
     text = "<html>\n<head>\n<title>Pop Window</title>\n<body>\n"; 
     text += "<center>\n<br>"; 
     text += "<h4 style="display:inline">Like us on </h4>" + "<a href='myLink' target='_blank' style="text-decoration:none; display:inline"> <h4 style="display:inline">Facebook</h4></a>" + " <h4 style="display:inline"> and win a prize</h4>"; 
     text += "</center>\n</body>\n</html>\n"; 
     setTimeout('windowProp(text)', 1000); 
} 

display:inlineは、すべての余分なものの下線のように削除要素が1行

text-decoration:noneに来ることができます。

+0

タグを1つだけ作ることもできます。

Facebookを賞賛して勝利賞

0

cssファイルでスタイリングしてください。あなたのケースでは、アンダーラインを削除するために、Facebook divのIDを設定し、text-decorationをnoneに設定することができます。さらに、それを1行に表示するには、float:leftまたはdisplay:inlineのいずれかを使用できます。ブロック要素をインライン要素に変換するので、float:leftを使用できます。同様

JS下:

function popupWin() { 
text = "<html>\n<head>\n<title>Pop Window</title>\n<body>\n"; 
text += "<center>\n<br>"; 
text += "<h4>Like us on</h4>" + "<h4><a href='myLink' target='_blank' id="facebook" Facebook</a></4>" + "<h4>and win a prize</h4>"; 
text += "</center>\n</body>\n</html>\n"; 
setTimeout('windowProp(text)', 1000); 
} 
function windowProp(text) { 
newWindow = window.open('','newWin','width=300,height=200'); 
newWindow.document.write(text); 
} 

CSS:

#facebook { 
    text-decoration: none; 
} 
h4 { 
    float:left // or display:inline 
} 

P/S:各H4はブロック要素であるため、それとも、単に、すべての不要なH4タグを削除することができ、それはよそう新しいh4タグが作成されたときに自動的に新しいものを作成します。したがって、1つのh4タグしか使用しない場合、新しい行は作成されません。ちょうど上記の答えのように。

関連する問題