2016-09-09 4 views
0

필자는 "필승을위한 페이스 북의 우리처럼."라고 제 본문을 말하고 싶습니다. 나는 "Facebook"이라는 단어가 링크되어 있지만 밑줄이 그어지기를 원하지 않습니다. 나는 또한 텍스트와 링크가 한 줄에 있도록하고 싶다. Here is what the output looks like now텍스트를 수정하여 한 줄에 표시하려면 어떻게합니까?

여기 내 코드입니다.

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

각 '

'은 (는) 블록입니다. 당신은 세 가지 필요하지 않습니다, 당신은 아마 하나의 콘텐츠 안에 있습니다. – 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를 만들기에 충분하다. 당신은 그것을 곱할 필요가 없습니다.

페이스 북의 링크는 인라인 HTML 속성 style 인 CSS text-decoration: none입니다.

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는 모든 여분의 물건 밑줄처럼 제거 요소가 한 줄

text-decoration:none 올 수 있습니다.

+0

아니면 그냥

태그 하나만 만들면됩니다.

Facebook을 좋아하고 우승 상 상품

0

CSS 파일로 스타일을 개선하는 것이 좋습니다. 귀하의 경우 밑줄을 제거하기 위해 Facebook div의 ID를 설정하고 text-decoration 스타일을 none으로 설정할 수 있습니다. 또한 한 줄에 표시하려면 float : left 또는 display : inline을 사용할 수 있습니다. float : left는 블록 요소를 인라인 요소로 바꾸기 때문에 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 태그가 만들어지면 자동으로 새 것으로 만듭니다. 따라서 하나의 h4 태그 만 사용하면 새로운 행을 만들 수 없습니다. 위의 대답과 같습니다.

관련 문제